Documentation ¶
Index ¶
Constants ¶
View Source
const MethodWild = "*"
MethodWild wild HTTP method
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Concurrency int ListenAddress string MaxBodySize int MaxIdleTime time.Duration Protocol gateway.Protocol ExternalAddrs []string Mux *Mux }
Config
type Gateway ¶
type Gateway struct { gateway.ConnectHandler gateway.MessageHandler gateway.CloseHandler // contains filtered or unexported fields }
Gateway
func (*Gateway) Run ¶
func (g *Gateway) Run()
Run is blocking and runs the server endless loop until a non-temporary error happens
func (*Gateway) Start ¶
func (g *Gateway) Start()
Start is non-blocking and call the Run function in background
func (*Gateway) TotalConnections ¶
type Mux ¶ added in v0.5.23
type Mux struct { // Enables automatic redirection if the current route can't be matched but a // handler for the path with (without) the trailing slash exists. // For example if /foo/ is requested but a route only exists for /foo, the // client is redirected to /foo with http status code 301 for GET requests // and 308 for all other request methods. RedirectTrailingSlash bool // If enabled, the router tries to fix the current request path, if no // handle is registered for it. // First superfluous path elements like ../ or // are removed. // Afterwards the router does a case-insensitive lookup of the cleaned path. // If a handle can be found for this route, the router makes a redirection // to the corrected path with status code 301 for GET requests and 308 for // all other request methods. // For example /FOO and /..//Foo could be redirected to /foo. // RedirectTrailingSlash is independent of this option. RedirectFixedPath bool // If enabled, the router checks if another method is allowed for the // current route, if the current request can not be routed. // If this is the case, the request is answered with 'Method Not Allowed' // and HTTP status code 405. // If no other Method is allowed, the request is delegated to the NotFound // handler. HandleMethodNotAllowed bool // If enabled, the router automatically replies to OPTIONS requests. // Custom OPTIONS handlers take priority over automatic replies. HandleOPTIONS bool // An optional gateway.MuxHandler that is called on automatic OPTIONS requests. // The handler is only called if HandleOPTIONS is true and no OPTIONS // handler for the specific path was set. // The "Allowed" header is set before calling the handler. GlobalOPTIONS gateway.MuxHandler // Configurable gateway.MuxHandler which is called when no matching route is // found. If it is not set, default NotFound is used. NotFound gateway.MuxHandler // Configurable MuxHandler which is called when a request // cannot be routed and HandleMethodNotAllowed is true. // If it is not set, ctx.Error with fasthttp.StatusMethodNotAllowed is used. // The "Allow" header with allowed request methods is set before the handler // is called. MethodNotAllowed gateway.MuxHandler // contains filtered or unexported fields }
func (*Mux) Handle ¶ added in v0.5.23
func (r *Mux) Handle(method, path string, handler gateway.MuxHandler)
Handle registers a new request handler with the given path and method.
For GET, POST, PUT, PATCH and DELETE requests the respective shortcut functions can be used.
This function is intended for bulk loading and to allow the usage of less frequently used, non-standardized or custom methods (e.g. for internal communication with a proxy).
Source Files ¶
Click to show internal directories.
Click to hide internal directories.