Documentation
¶
Index ¶
- Variables
- type App
- func (a *App) DELETE(path string, handler HandlerFunc, middleware ...Middleware)
- func (a *App) GET(path string, handler HandlerFunc, middleware ...Middleware)
- func (a *App) Group(prefix string, middleware ...Middleware) *Group
- func (a *App) Listen(port ...string) error
- func (a *App) OPTIONS(path string, handler HandlerFunc, middleware ...Middleware)
- func (a *App) PATCH(path string, handler HandlerFunc, middleware ...Middleware)
- func (a *App) POST(path string, handler HandlerFunc, middleware ...Middleware)
- func (a *App) PUT(path string, handler HandlerFunc, middleware ...Middleware)
- func (a *App) Use(middleware ...Middleware)
- type Config
- type Context
- func (c *Context) Body() ([]byte, error)
- func (c *Context) BodyParser(v interface{}) error
- func (c *Context) Cookie(cookie *http.Cookie) *Context
- func (c *Context) FormFile(name string) (*multipart.FileHeader, error)
- func (c *Context) FormValue(name string) string
- func (c *Context) Get(key string) (interface{}, bool)
- func (c *Context) GetCookie(name string) (*http.Cookie, error)
- func (c *Context) GetStatus() int
- func (c *Context) HTML(html string) error
- func (c *Context) Header(name string) string
- func (c *Context) IP() string
- func (c *Context) JSON(data interface{}) error
- func (c *Context) Method() string
- func (c *Context) MustGet(key string) interface{}
- func (c *Context) Param(name string) string
- func (c *Context) Path() string
- func (c *Context) Query(name string) string
- func (c *Context) QueryDefault(name, defaultValue string) string
- func (c *Context) QueryInt(name string) (int, error)
- func (c *Context) Redirect(url string, code ...int) error
- func (c *Context) Send(data []byte) error
- func (c *Context) Set(key string, value interface{})
- func (c *Context) SetHeader(name, value string) *Context
- func (c *Context) SetParam(name, value string)
- func (c *Context) Status(code int) *Context
- func (c *Context) String(s string) error
- func (c *Context) UserAgent() string
- func (c *Context) XML(data interface{}) error
- type Group
- func (g *Group) DELETE(path string, handler HandlerFunc, middleware ...Middleware)
- func (g *Group) GET(path string, handler HandlerFunc, middleware ...Middleware)
- func (g *Group) Group(prefix string, middleware ...Middleware) *Group
- func (g *Group) OPTIONS(path string, handler HandlerFunc, middleware ...Middleware)
- func (g *Group) PATCH(path string, handler HandlerFunc, middleware ...Middleware)
- func (g *Group) POST(path string, handler HandlerFunc, middleware ...Middleware)
- func (g *Group) PUT(path string, handler HandlerFunc, middleware ...Middleware)
- func (g *Group) Use(middleware ...Middleware)
- type HTTPError
- type HandlerFunc
- type Middleware
Constants ¶
This section is empty.
Variables ¶
var ( ErrBadRequest = NewHTTPError(http.StatusBadRequest, "Bad request") ErrForbidden = NewHTTPError(http.StatusForbidden, "Forbidden") ErrNotFound = NewHTTPError(http.StatusNotFound, "Not found") ErrMethodNotAllowed = NewHTTPError(http.StatusMethodNotAllowed, "Method not allowed") ErrConflict = NewHTTPError(http.StatusConflict, "Conflict") ErrInternalServerError = NewHTTPError(http.StatusInternalServerError, "Internal server error") )
Common HTTP errors
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the main application struct
func (*App) DELETE ¶
func (a *App) DELETE(path string, handler HandlerFunc, middleware ...Middleware)
DELETE registers a DELETE route
func (*App) GET ¶
func (a *App) GET(path string, handler HandlerFunc, middleware ...Middleware)
GET registers a GET route
func (*App) Group ¶
func (a *App) Group(prefix string, middleware ...Middleware) *Group
Group creates a new route group
func (*App) OPTIONS ¶
func (a *App) OPTIONS(path string, handler HandlerFunc, middleware ...Middleware)
OPTIONS registers an OPTIONS route
func (*App) PATCH ¶
func (a *App) PATCH(path string, handler HandlerFunc, middleware ...Middleware)
PATCH registers a PATCH route
func (*App) POST ¶
func (a *App) POST(path string, handler HandlerFunc, middleware ...Middleware)
POST registers a POST route
func (*App) PUT ¶
func (a *App) PUT(path string, handler HandlerFunc, middleware ...Middleware)
PUT registers a PUT route
func (*App) Use ¶
func (a *App) Use(middleware ...Middleware)
Use adds middleware to the application
type Config ¶
type Config struct {
Port string
ReadTimeout time.Duration
WriteTimeout time.Duration
ShutdownTimeout time.Duration
EnableLogging bool
}
Config holds application configuration
type Context ¶
type Context struct {
Request *http.Request
Response http.ResponseWriter
// contains filtered or unexported fields
}
Context wraps the HTTP request and response
func NewContext ¶
func NewContext(w http.ResponseWriter, r *http.Request) *Context
NewContext creates a new Context
func (*Context) BodyParser ¶
BodyParser parses the request body into the given struct
func (*Context) FormFile ¶
func (c *Context) FormFile(name string) (*multipart.FileHeader, error)
FormFile gets a file from a multipart form
func (*Context) QueryDefault ¶
QueryDefault gets a query parameter with a default value
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group represents a route group
func (*Group) DELETE ¶
func (g *Group) DELETE(path string, handler HandlerFunc, middleware ...Middleware)
DELETE registers a DELETE route in the group
func (*Group) GET ¶
func (g *Group) GET(path string, handler HandlerFunc, middleware ...Middleware)
GET registers a GET route in the group
func (*Group) Group ¶
func (g *Group) Group(prefix string, middleware ...Middleware) *Group
Group creates a nested group
func (*Group) OPTIONS ¶
func (g *Group) OPTIONS(path string, handler HandlerFunc, middleware ...Middleware)
OPTIONS registers an OPTIONS route in the group
func (*Group) PATCH ¶
func (g *Group) PATCH(path string, handler HandlerFunc, middleware ...Middleware)
PATCH registers a PATCH route in the group
func (*Group) POST ¶
func (g *Group) POST(path string, handler HandlerFunc, middleware ...Middleware)
POST registers a POST route in the group
func (*Group) PUT ¶
func (g *Group) PUT(path string, handler HandlerFunc, middleware ...Middleware)
PUT registers a PUT route in the group
type HTTPError ¶
HTTPError represents an HTTP error
func NewHTTPError ¶
NewHTTPError creates a new HTTP error
type HandlerFunc ¶
HandlerFunc is the main handler function type
type Middleware ¶
type Middleware func(HandlerFunc) HandlerFunc
Middleware is a function that wraps a handler
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
auth
command
|
|
|
basic
command
|
|
|
microservices
command
|
|
|
todo-api
command
|
|