Documentation ¶
Overview ¶
Copyright (c) 2023 Tiago Melo. All rights reserved. Use of this source code is governed by the MIT License that can be found in the LICENSE file.
Copyright (c) 2023 Tiago Melo. All rights reserved. Use of this source code is governed by the MIT License that can be found in the LICENSE file.
Copyright (c) 2023 Tiago Melo. All rights reserved. Use of this source code is governed by the MIT License that can be found in the LICENSE file.
Copyright (c) 2023 Tiago Melo. All rights reserved. Use of this source code is governed by the MIT License that can be found in the LICENSE file.
Copyright (c) 2023 Tiago Melo. All rights reserved. Use of this source code is governed by the MIT License that can be found in the LICENSE file.
Copyright (c) 2023 Tiago Melo. All rights reserved. Use of this source code is governed by the MIT License that can be found in the LICENSE file.
Index ¶
- func Decode(r *http.Request, val any) error
- func IsShutdown(err error) bool
- func NewShutdownError(message string) error
- func Param(r *http.Request, key string) string
- func Respond(ctx context.Context, w http.ResponseWriter, data any, statusCode int) error
- func SetStatusCode(ctx context.Context, statusCode int) error
- type App
- type Handler
- type Middleware
- type Values
Constants ¶
This section is empty.
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 IsShutdown ¶
IsShutdown checks to see if the shutdown error is contained in the specified error value.
func NewShutdownError ¶
NewShutdownError returns an error that causes the framework to signal a graceful shutdown.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the entrypoint into our application and what configures our context object for each of our http handlers.
func NewApp ¶
func NewApp(shutdown chan os.Signal, mw ...Middleware) *App
NewApp creates an App value that handle a set of routes for the application.
func (*App) Handle ¶
Handle sets a handler function for a given HTTP method and path pair to the application server mux.
func (*App) ServeHTTP ¶
func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface. It's the entry point for all http traffic.
func (*App) SignalShutdown ¶
func (a *App) SignalShutdown()
SignalShutdown is used to gracefully shut down the app when an integrity issue is identified.
type Middleware ¶
Middleware is a function designed to run some code before and/or after another Handler. It is designed to remove boilerplate or other concerns not direct to any given Handler.