Documentation ¶
Overview ¶
Package supernova is a fasthttp router that implements a radix tree for fast lookups
Index ¶
- func NewGracefulListener(ln net.Listener, maxWaitTime time.Duration) net.Listener
- type CachedObj
- type CachedStatic
- type GracefulListener
- type JSONError
- type JSONErrors
- type Middleware
- type Node
- type Request
- func (r *Request) Error(statusCode int, msg string, errors ...interface{}) (int, error)
- func (r *Request) GetMethod() string
- func (r *Request) JSON(code int, obj interface{}) (int, error)
- func (r *Request) QueryParam(key string) string
- func (r *Request) ReadJSON(i interface{}) error
- func (r *Request) RouteParam(key string) string
- func (r *Request) Send(data interface{}) (int, error)
- type Route
- type Server
- func (sn *Server) All(route string, routeFunc func(*Request))
- func (sn *Server) Close() error
- func (sn *Server) Delete(route string, routeFunc func(*Request))
- func (sn *Server) EnableDebug(debug bool)
- func (sn *Server) Get(route string, routeFunc func(*Request))
- func (sn *Server) ListenAndServe(addr string) error
- func (sn *Server) ListenAndServeTLS(addr, certFile, keyFile string) error
- func (sn *Server) Post(route string, routeFunc func(*Request))
- func (sn *Server) Put(route string, routeFunc func(*Request))
- func (sn *Server) Restricted(method, route string, routeFunc func(*Request))
- func (sn *Server) Serve(ln net.Listener) error
- func (sn *Server) SetShutDownHandler(shutdownFunc func())
- func (sn *Server) Use(f func(*Request, func()))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CachedObj ¶
type CachedObj struct {
// contains filtered or unexported fields
}
CachedObj represents a static asset
type CachedStatic ¶
type CachedStatic struct {
// contains filtered or unexported fields
}
CachedStatic holds all cached static assets in memory
type GracefulListener ¶
type GracefulListener struct {
// contains filtered or unexported fields
}
GracefulListener is used as custom listener to watch connections
func (*GracefulListener) Accept ¶
func (ln *GracefulListener) Accept() (net.Conn, error)
Accept waits for connection increments count and returns to the listener.
func (*GracefulListener) Addr ¶
func (ln *GracefulListener) Addr() net.Addr
Addr returns the listener's network address.
func (*GracefulListener) Close ¶
func (ln *GracefulListener) Close() error
Close closes the inner listener and waits until all the pending open connections are closed before returning.
type JSONError ¶
type JSONError struct { Errors []interface{} `json:"errors"` Code int `json:"code"` Message string `json:"message"` }
JSONError resembles the RESTful standard for an error response
type JSONErrors ¶
type JSONErrors struct {
Error JSONError `json:"error"`
}
JSONErrors holds the JSONError response
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware holds all middleware functions
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node holds a single route with accompanying children routes
type Request ¶
type Request struct { *fasthttp.RequestCtx BaseUrl string // Writer is used to write to response body Writer io.Writer Ctx context.Context // contains filtered or unexported fields }
Request resembles an incoming request
func NewRequest ¶
func NewRequest(ctx *fasthttp.RequestCtx) *Request
NewRequest creates a new Request pointer for an incoming request
func (*Request) GetMethod ¶
GetMethod provides a simple way to return the request method type as a string
func (*Request) QueryParam ¶
QueryParam checks for and returns param or "" if doesn't exist
func (*Request) RouteParam ¶
RouteParam checks for and returns param or "" if doesn't exist
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route is the construct of a single route pattern
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the router and all associated data
func (*Server) EnableDebug ¶
EnableDebug toggles output for incoming requests
func (*Server) ListenAndServe ¶
ListenAndServe starts the server
func (*Server) ListenAndServeTLS ¶
ListenAndServeTLS starts server with ssl
func (*Server) Restricted ¶
Restricted adds route that is restricted by method
func (*Server) SetShutDownHandler ¶
func (sn *Server) SetShutDownHandler(shutdownFunc func())
SetShutDownHandler implements function called when SIGTERM signal is received