Documentation ¶
Index ¶
- func Listen(h *Handler) error
- func NewContext(ctx context.Context, log shared.Logger, address string, origin string, ...) (context.Context, error)
- type Handler
- func (h Handler) Abort(w http.ResponseWriter, message string, code int)
- func (h Handler) Error(w http.ResponseWriter, err error, code int)
- func (h Handler) JSON(data io.ReadCloser, result interface{}) error
- func (h Handler) Respond(w http.ResponseWriter, message string, data interface{})
- func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h Handler) Static(path string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContext ¶
func NewContext(ctx context.Context, log shared.Logger, address string, origin string, rate float64, burst int, ttl time.Duration, out string, prefix string) (context.Context, error)
NewContext is the utility to encapsulate pkg-scoped context values by preventing context key collision.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is the application HTTP handler.
func (Handler) Abort ¶
func (h Handler) Abort(w http.ResponseWriter, message string, code int)
Abort is a helper to respond HTTP requests with errors.
func (Handler) Error ¶
func (h Handler) Error(w http.ResponseWriter, err error, code int)
Error is a helper to abort HTTP requests with errors.
func (Handler) JSON ¶
func (h Handler) JSON(data io.ReadCloser, result interface{}) error
JSON is a helper to encode data in JSON format.
func (Handler) Respond ¶
func (h Handler) Respond(w http.ResponseWriter, message string, data interface{})
Respond is a helper to respond HTTP requests.
Click to show internal directories.
Click to hide internal directories.