Documentation ¶
Index ¶
- func GetParams(r *http.Request) map[string]string
- func GetStatus(ctx context.Context) int
- func GetTime(ctx context.Context) time.Time
- func GetTraceID(ctx context.Context) string
- func IsShutdown(err error) bool
- func NewShutdownErr(msg string) error
- func ParseBodyJSON(r *http.Request, val interface{}) error
- func RespondJSON(ctx context.Context, w http.ResponseWriter, data interface{}, statusCode int) error
- func SetStatusCode(ctx context.Context, statusCode int) error
- type Handler
- type Middleware
- type Router
- func (r *Router) DELETE(pth string, handler Handler, mws ...Middleware)
- func (r *Router) GET(pth string, handler Handler, mws ...Middleware)
- func (r *Router) Group(sub string, mws ...Middleware) *Router
- func (r *Router) PATCH(pth string, handler Handler, mws ...Middleware)
- func (r *Router) POST(pth string, handler Handler, mws ...Middleware)
- func (r *Router) PUT(pth string, handler Handler, mws ...Middleware)
- func (r *Router) Prepare()
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) SignalShutdown()
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTraceID ¶
GetTraceID returns the traceID from the context
func NewShutdownErr ¶
NewShutdownErr returns an error that will cause an graceful app shutdown
func ParseBodyJSON ¶
ParseBodyJSON reads the body of an HTTP request looking for a JSON document. The body is decoded into the provided value.
func RespondJSON ¶
func RespondJSON(ctx context.Context, w http.ResponseWriter, data interface{}, statusCode int) error
RespondJSON converts a Go value to JSON and sends it to the client.
Types ¶
type Middleware ¶
Middleware represents a function designed to run some code before/after another handler
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is a wrapper around a net/http server and the razonyang/fastrouter to tie it together
with a logger and the shutdown channel
func (*Router) DELETE ¶
func (r *Router) DELETE(pth string, handler Handler, mws ...Middleware)
DELETE is a shortcut for group.Handle("DELETE", path, handler)
func (*Router) GET ¶
func (r *Router) GET(pth string, handler Handler, mws ...Middleware)
GET is a shortcut for group.Handle("GET", path, handler)
func (*Router) Group ¶
func (r *Router) Group(sub string, mws ...Middleware) *Router
Group returns a new group
func (*Router) PATCH ¶
func (r *Router) PATCH(pth string, handler Handler, mws ...Middleware)
PATCH is a shortcut for group.Handle("PATCH", path, handler)
func (*Router) POST ¶
func (r *Router) POST(pth string, handler Handler, mws ...Middleware)
POST is a shortcut for group.Handle("POST", path, handler)
func (*Router) PUT ¶
func (r *Router) PUT(pth string, handler Handler, mws ...Middleware)
PUT is a shortcut for group.Handle("PUT", path, handler)
func (*Router) ServeHTTP ¶
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP makes the router implement the http.Handler interface.
func (*Router) SignalShutdown ¶
func (r *Router) SignalShutdown()
SignalShutdown sends the app wide terminate signal