Documentation
¶
Index ¶
- func DirCache(dir string) autocert.Cache
- type Context
- func (c *Context) BadRequest() *Context
- func (c *Context) Conflict() *Context
- func (c *Context) Created() *Context
- func (c *Context) Empty() *EmptyResponse
- func (c *Context) File(path string) *FileResponse
- func (c *Context) Forbidden() *Context
- func (c *Context) Get(key string) interface{}
- func (c *Context) InternalServerError() *Context
- func (c *Context) JSON(value interface{}) *JSONResponse
- func (c *Context) LogAlert(message interface{})
- func (c *Context) LogCritical(message interface{})
- func (c *Context) LogDebug(message interface{})
- func (c *Context) LogEmergency(message interface{})
- func (c *Context) LogError(message interface{})
- func (c *Context) LogInfo(message interface{})
- func (c *Context) LogNotice(message interface{})
- func (c *Context) LogWarning(message interface{})
- func (c *Context) NotFound() *Context
- func (c *Context) Param(name string) string
- func (c *Context) ParseJSON(target interface{}) error
- func (c *Context) Push(path string) error
- func (c *Context) Query(name string) string
- func (c *Context) Set(key string, value interface{})
- func (c *Context) SetCookie(cookie *http.Cookie)
- func (c *Context) Status(status int) *Context
- func (c *Context) Text(text string) *TextResponse
- func (c *Context) Unauthorized() *Context
- func (c *Context) UnprocessableEntity() *Context
- type EmptyResponse
- type Engine
- func (e *Engine) AddCustomLogger(logger Logger)
- func (e *Engine) AddStdLogger(level LogLevel)
- func (e *Engine) DELETE(path string, handler Handler)
- func (e *Engine) GET(path string, handler Handler)
- func (e *Engine) GzipAndServeFiles(path string, directory string, size int64)
- func (e *Engine) HEAD(path string, handler Handler)
- func (e *Engine) Middleware(middleware ...Handler) *Middleware
- func (e *Engine) NotFound(handler Handler)
- func (e *Engine) OPTIONS(path string, handler Handler)
- func (e *Engine) PATCH(path string, handler Handler)
- func (e *Engine) POST(path string, handler Handler)
- func (e *Engine) PUT(path string, handler Handler)
- func (e *Engine) RedirectWWW()
- func (e *Engine) Run(port string) error
- func (e *Engine) RunTLS(config *TLSConfig) error
- func (e *Engine) ServeFiles(path string, directory string)
- func (e *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (e *Engine) Shutdown() error
- func (e *Engine) WebSocket(path string, handler websocket.Handler)
- type FileResponse
- type Handler
- type JSONResponse
- type LogLevel
- type Logger
- type Map
- type Middleware
- func (m *Middleware) DELETE(path string, handler Handler)
- func (m *Middleware) GET(path string, handler Handler)
- func (m *Middleware) HEAD(path string, handler Handler)
- func (m *Middleware) OPTIONS(path string, handler Handler)
- func (m *Middleware) PATCH(path string, handler Handler)
- func (m *Middleware) POST(path string, handler Handler)
- func (m *Middleware) PUT(path string, handler Handler)
- type Responder
- type TLSConfig
- type TextResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct { ResponseWriter http.ResponseWriter Request *http.Request // contains filtered or unexported fields }
Context provides helper methods to read the request, get and set values in a data store, and send a response to the client. A new Context is constructed for each request, and is dropped when the response is sent.
func (*Context) BadRequest ¶
BadRequest sets the response status to 400.
func (*Context) Empty ¶ added in v0.8.0
func (c *Context) Empty() *EmptyResponse
Empty returns a EmptyResponse.
func (*Context) InternalServerError ¶
InternalServerError sets the response status to 500.
func (*Context) JSON ¶
func (c *Context) JSON(value interface{}) *JSONResponse
JSON returns a JSONResponse.
func (*Context) LogAlert ¶
func (c *Context) LogAlert(message interface{})
LogAlert logs the given messages for all loggers where ShouldLog(LogLevelAlert) method returns true.
func (*Context) LogCritical ¶
func (c *Context) LogCritical(message interface{})
LogCritical logs the given messages for all loggers where ShouldLog(LogLevelCritical) method returns true.
func (*Context) LogDebug ¶
func (c *Context) LogDebug(message interface{})
LogDebug logs the given messages for all loggers where ShouldLog(LogLevelDebug) method returns true.
func (*Context) LogEmergency ¶
func (c *Context) LogEmergency(message interface{})
LogEmergency logs the given messages for all loggers where ShouldLog(LogLevelEmergency) method returns true.
func (*Context) LogError ¶
func (c *Context) LogError(message interface{})
LogError logs the given messages for all loggers where ShouldLog(LogLevelError) method returns true.
func (*Context) LogInfo ¶
func (c *Context) LogInfo(message interface{})
LogInfo logs the given messages for all loggers where ShouldLog(LogLevelInfo) method returns true.
func (*Context) LogNotice ¶
func (c *Context) LogNotice(message interface{})
LogNotice logs the given messages for all loggers where ShouldLog(LogLevelNotice) method returns true.
func (*Context) LogWarning ¶
func (c *Context) LogWarning(message interface{})
LogWarning logs the given messages for all loggers where ShouldLog(LogLevelWarning) method returns true.
func (*Context) Param ¶
Param gets a path parameter by the given name. An Empty string is returned if a parameter by the given name doesn't exist.
func (*Context) Query ¶
Query gets a query value by the given name. An empty string is returned if a value by the given name doesn't exist.
func (*Context) Text ¶ added in v0.7.0
func (c *Context) Text(text string) *TextResponse
Text returns a TextResponse.
func (*Context) Unauthorized ¶
Unauthorized sets the response status to 401.
func (*Context) UnprocessableEntity ¶
UnprocessableEntity sets the response status to 422.
type EmptyResponse ¶ added in v0.8.0
type EmptyResponse struct {
// contains filtered or unexported fields
}
EmptyResponse implements Responder interface.
func (*EmptyResponse) Respond ¶ added in v0.8.0
func (r *EmptyResponse) Respond()
Respond sends a JSON response.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine contains routing and logging information for your app.
func (*Engine) AddCustomLogger ¶
AddCustomLogger adds a Logger to the Engine.
func (*Engine) AddStdLogger ¶
AddStdLogger adds a logger that will output log messages with log.Println.
func (*Engine) GzipAndServeFiles ¶
GzipAndServeFiles will serve files from the given directory with the given path. If the file size is greater than the given size, a gzipped version of the file will be created and served.
func (*Engine) Middleware ¶ added in v0.9.0
func (e *Engine) Middleware(middleware ...Handler) *Middleware
Middleware returns a new middleware chain.
func (*Engine) RedirectWWW ¶
func (e *Engine) RedirectWWW()
RedirectWWW redirects all requests to the non-www host.
func (*Engine) ServeFiles ¶
ServeFiles will serve files from the given directory with the given path.
func (*Engine) ServeHTTP ¶
func (e *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface.
type FileResponse ¶
type FileResponse struct {
// contains filtered or unexported fields
}
FileResponse implements Responder interface.
type JSONResponse ¶
type JSONResponse struct {
// contains filtered or unexported fields
}
JSONResponse implements Responder interface.
type LogLevel ¶
type LogLevel int
LogLevel as defined in the RFC 5424 specification.
const ( // LogLevelDebug as defined in the RFC 5424 specification. LogLevelDebug LogLevel = 1 // LogLevelInfo as defined in the RFC 5424 specification. LogLevelInfo LogLevel = 2 // LogLevelNotice as defined in the RFC 5424 specification. LogLevelNotice LogLevel = 3 // LogLevelWarning as defined in the RFC 5424 specification. LogLevelWarning LogLevel = 4 // LogLevelError as defined in the RFC 5424 specification. LogLevelError LogLevel = 5 // LogLevelCritical as defined in the RFC 5424 specification. LogLevelCritical LogLevel = 6 // LogLevelAlert as defined in the RFC 5424 specification. LogLevelAlert LogLevel = 7 // LogLevelEmergency as defined in the RFC 5424 specification. LogLevelEmergency LogLevel = 8 )
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware contains a set of Handler functions that will be applied in the same order in which they were registered.
func (*Middleware) DELETE ¶ added in v0.9.0
func (m *Middleware) DELETE(path string, handler Handler)
DELETE registers a route for method DELETE.
func (*Middleware) GET ¶ added in v0.9.0
func (m *Middleware) GET(path string, handler Handler)
GET registers a route for method GET.
func (*Middleware) HEAD ¶ added in v0.9.0
func (m *Middleware) HEAD(path string, handler Handler)
HEAD registers a route for method HEAD.
func (*Middleware) OPTIONS ¶ added in v0.9.0
func (m *Middleware) OPTIONS(path string, handler Handler)
OPTIONS registers a route for method OPTIONS.
func (*Middleware) PATCH ¶ added in v0.9.0
func (m *Middleware) PATCH(path string, handler Handler)
PATCH registers a route for method PATCH.
func (*Middleware) POST ¶ added in v0.9.0
func (m *Middleware) POST(path string, handler Handler)
POST registers a route for method POST.
func (*Middleware) PUT ¶ added in v0.9.0
func (m *Middleware) PUT(path string, handler Handler)
PUT registers a route for method PUT.
type Responder ¶
type Responder interface {
Respond()
}
Responder is the Responder interface that responds to HTTP requests.
type TextResponse ¶ added in v0.7.0
type TextResponse struct {
// contains filtered or unexported fields
}
TextResponse implements Responder interface.
func (*TextResponse) Respond ¶ added in v0.7.0
func (r *TextResponse) Respond()
Respond sends a plain text response.