Documentation
¶
Index ¶
- func Decode(r *http.Request, v Decoder) error
- func GetWriter(ctx context.Context) http.ResponseWriter
- func Param(r *http.Request, key string) string
- func Respond(ctx context.Context, w http.ResponseWriter, dataModel Encoder) error
- type App
- func (a *App) EnableCORS(origins []string)
- func (a *App) FileServer(static embed.FS, dir string, path string) error
- func (a *App) FileServerReact(static embed.FS, dir string, path string) error
- func (a *App) HandlerFunc(method string, group string, path string, handlerFunc HandlerFunc, ...)
- func (a *App) HandlerFuncNoMid(method string, group string, path string, handlerFunc HandlerFunc)
- func (a *App) RawHandlerFunc(method string, group string, path string, rawHandlerFunc http.HandlerFunc, ...)
- func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Decoder
- type Encoder
- type HandlerFunc
- type Logger
- type MidFunc
- type NoResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode reads the body of an HTTP request and decodes the body into the specified data model. If the data model implements the validator interface, the method will be called.
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. Feel free to add any configuration data/logic on this App struct.
func (*App) EnableCORS ¶
func (*App) FileServer ¶
FileServer starts a file server based on the specified file system and directory inside that file system.
func (*App) FileServerReact ¶
FileServerReact starts a file server based on the specified file system and directory inside that file system for a statically built react webapp.
func (*App) HandlerFunc ¶
func (*App) HandlerFuncNoMid ¶
func (a *App) HandlerFuncNoMid(method string, group string, path string, handlerFunc HandlerFunc)
func (*App) RawHandlerFunc ¶
func (a *App) RawHandlerFunc(method string, group string, path string, rawHandlerFunc http.HandlerFunc, mw ...MidFunc)
RawHandlerFunc sets a raw handler function for a given HTTP method and path pair to the application server mux.
type Encoder ¶
Encoder defines behavior that can encode a data model and provide the content type for that encoding.
type HandlerFunc ¶
HandlerFunc represents a function that handles a http request within our own little mini framework.
type MidFunc ¶
type MidFunc func(handler HandlerFunc) HandlerFunc
type NoResponse ¶
type NoResponse struct{}