Documentation ¶
Index ¶
- Constants
- func Decode(r *http.Request, val interface{}) error
- func NewError(statusCode int, message string) error
- func NewErrorf(status int, format string, args ...interface{}) error
- func Param(r *http.Request, key string) string
- func Respond(_ context.Context, w http.ResponseWriter, data interface{}, statusCode int) error
- type Application
- type Error
- type Handler
Constants ¶
const DefaultShutdownTimeout = 10 * time.Second
DefaultShutdownTimeout sets the maximum amount of time to wait for the server to shutdown gracefully.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode reads the body of an HTTP request looking for a JSON document. The body is decoded into the provided value.
If the provided value is a struct then it is checked for validation tags.
func NewErrorf ¶
NewErrorf creates a new error with the given status code and the message formatted according to args and format.
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application is contains all required base components for building web applications.
func New ¶
func New() *Application
New creates an Application that handles a set of routes for the application.
func (*Application) Method ¶
func (app *Application) Method(method, pattern string, h http.Handler)
Method adds the route `pattern` that matches `method` http method to execute the `handler` http.Handler.
func (*Application) Run ¶
func (app *Application) Run() error
Run is called to start the web service.
func (*Application) ServeHTTP ¶
func (app *Application) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface.