mirror of https://github.com/gofiber/fiber.git
commit
c7a0449362
12
app.go
12
app.go
|
@ -29,7 +29,7 @@ import (
|
|||
)
|
||||
|
||||
// Version of current package
|
||||
const Version = "1.12.4"
|
||||
const Version = "1.12.5"
|
||||
|
||||
// Map is a shortcut for map[string]interface{}, useful for JSON returns
|
||||
type Map map[string]interface{}
|
||||
|
@ -411,11 +411,17 @@ func (app *App) Routes() []*Route {
|
|||
return routes
|
||||
}
|
||||
|
||||
// Serve can be used to pass a custom listener
|
||||
// Serve is deprecated, please use app.Listener()
|
||||
func (app *App) Serve(ln net.Listener, tlsconfig ...*tls.Config) error {
|
||||
fmt.Println("serve: app.Serve() is deprecated since v1.12.5, please use app.Listener()")
|
||||
return app.Listener(ln, tlsconfig...)
|
||||
}
|
||||
|
||||
// Listener can be used to pass a custom listener
|
||||
// This method does not support the Prefork feature
|
||||
// Prefork is not supported using app.Serve(ln net.Listener)
|
||||
// You can pass an optional *tls.Config to enable TLS.
|
||||
func (app *App) Serve(ln net.Listener, tlsconfig ...*tls.Config) error {
|
||||
func (app *App) Listener(ln net.Listener, tlsconfig ...*tls.Config) error {
|
||||
// Update fiber server settings
|
||||
app.init()
|
||||
// TLS config
|
||||
|
|
24
utils.go
24
utils.go
|
@ -182,21 +182,27 @@ func parseTokenList(noneMatchBytes []byte) []string {
|
|||
|
||||
// https://golang.org/src/net/net.go#L113
|
||||
// Helper methods for application#test
|
||||
type testAddr string
|
||||
|
||||
func (a testAddr) Network() string {
|
||||
return string(a)
|
||||
}
|
||||
func (a testAddr) String() string {
|
||||
return string(a)
|
||||
}
|
||||
|
||||
type testConn struct {
|
||||
net.Conn
|
||||
r bytes.Buffer
|
||||
w bytes.Buffer
|
||||
}
|
||||
|
||||
func (c *testConn) RemoteAddr() net.Addr {
|
||||
return &net.TCPAddr{
|
||||
IP: net.IPv4(0, 0, 0, 0),
|
||||
}
|
||||
}
|
||||
func (c *testConn) LocalAddr() net.Addr { return c.RemoteAddr() }
|
||||
func (c *testConn) Read(b []byte) (int, error) { return c.r.Read(b) }
|
||||
func (c *testConn) Write(b []byte) (int, error) { return c.w.Write(b) }
|
||||
func (c *testConn) Close() error { return nil }
|
||||
func (c *testConn) Read(b []byte) (int, error) { return c.r.Read(b) }
|
||||
func (c *testConn) Write(b []byte) (int, error) { return c.w.Write(b) }
|
||||
func (c *testConn) Close() error { return nil }
|
||||
|
||||
func (c *testConn) LocalAddr() net.Addr { return testAddr("local-addr") }
|
||||
func (c *testConn) RemoteAddr() net.Addr { return testAddr("remote-addr") }
|
||||
func (c *testConn) SetDeadline(t time.Time) error { return nil }
|
||||
func (c *testConn) SetReadDeadline(t time.Time) error { return nil }
|
||||
func (c *testConn) SetWriteDeadline(t time.Time) error { return nil }
|
||||
|
|
Loading…
Reference in New Issue