Documentation ¶
Overview ¶
Package atreugo is a micro-framework to make simple the use of routing and middlewares with all optimizations of fasthttp
This micro-framework is build on top valyala's fasthttp fork.
Index ¶
- type Atreugo
- type Config
- type JSON
- type Middleware
- type RequestCtx
- func (ctx *RequestCtx) FileResponse(fileName, filePath, mimeType string) error
- func (ctx *RequestCtx) HTTPResponse(body []byte, statusCode ...int) error
- func (ctx *RequestCtx) JSONResponse(body interface{}, statusCode ...int) error
- func (ctx *RequestCtx) RawResponse(body []byte, statusCode ...int) error
- func (ctx *RequestCtx) RedirectResponse(url string, statusCode int) error
- func (ctx *RequestCtx) TextResponse(body []byte, statusCode ...int) error
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Atreugo ¶
type Atreugo struct {
// contains filtered or unexported fields
}
Atreugo struct for make up a server
func (*Atreugo) ListenAndServe ¶
ListenAndServe start Atreugo server according to the configuration
func (*Atreugo) SetLogOutput ¶
SetLogOutput set log output of server
func (*Atreugo) UseMiddleware ¶
func (s *Atreugo) UseMiddleware(fns ...Middleware)
UseMiddleware register middleware functions that viewHandler will use
type Config ¶
type Config struct { Host string Port int LogLevel string Compress bool TLSEnable bool CertKey string CertFile string GracefulShutdown bool }
Config config for Atreugo
type JSON ¶
type JSON map[string]interface{}
JSON is a map whose key is a string and whose value an interface
type Middleware ¶
type Middleware func(ctx *RequestCtx) (int, error)
Middleware must process all incoming requests before defined views.
type RequestCtx ¶
type RequestCtx struct {
*fasthttp.RequestCtx
}
RequestCtx context wrapper for fasthttp.RequestCtx to adds extra funtionality
func (*RequestCtx) FileResponse ¶
func (ctx *RequestCtx) FileResponse(fileName, filePath, mimeType string) error
FileResponse return a streaming response with file data.
func (*RequestCtx) HTTPResponse ¶
func (ctx *RequestCtx) HTTPResponse(body []byte, statusCode ...int) error
HTTPResponse return response with body in html format
func (*RequestCtx) JSONResponse ¶
func (ctx *RequestCtx) JSONResponse(body interface{}, statusCode ...int) error
JSONResponse return response with body in json format
func (*RequestCtx) RawResponse ¶
func (ctx *RequestCtx) RawResponse(body []byte, statusCode ...int) error
RawResponse returns response without encoding the body.
func (*RequestCtx) RedirectResponse ¶
func (ctx *RequestCtx) RedirectResponse(url string, statusCode int) error
RedirectResponse redirect request to an especific url
func (*RequestCtx) TextResponse ¶
func (ctx *RequestCtx) TextResponse(body []byte, statusCode ...int) error
TextResponse return response with body in text format