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 erikdubbelboer's fasthttp fork.
Index ¶
- func FileResponse(ctx *fasthttp.RequestCtx, fileName, filePath, mimeType string) error
- func HTTPResponse(ctx *fasthttp.RequestCtx, body []byte, statusCode ...int) error
- func JSONResponse(ctx *fasthttp.RequestCtx, body interface{}, statusCode ...int) error
- func RawResponse(ctx *fasthttp.RequestCtx, body []byte, statusCode ...int) error
- func RedirectResponse(ctx *fasthttp.RequestCtx, url string, statusCode int) error
- func TextResponse(ctx *fasthttp.RequestCtx, body []byte, statusCode ...int) error
- type Atreugo
- type Config
- type JSON
- type Middleware
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileResponse ¶ added in v3.1.0
func FileResponse(ctx *fasthttp.RequestCtx, fileName, filePath, mimeType string) error
FileResponse return a streaming response with file data.
func HTTPResponse ¶
func HTTPResponse(ctx *fasthttp.RequestCtx, body []byte, statusCode ...int) error
HTTPResponse return response with body in html format
func JSONResponse ¶
func JSONResponse(ctx *fasthttp.RequestCtx, body interface{}, statusCode ...int) error
JSONResponse return response with body in json format
func RawResponse ¶ added in v3.1.0
func RawResponse(ctx *fasthttp.RequestCtx, body []byte, statusCode ...int) error
RawResponse returns response without encoding the body.
func RedirectResponse ¶
func RedirectResponse(ctx *fasthttp.RequestCtx, url string, statusCode int) error
RedirectResponse redirect request to an especific url
func TextResponse ¶ added in v3.1.0
func TextResponse(ctx *fasthttp.RequestCtx, body []byte, statusCode ...int) error
TextResponse return response with body in text format
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) 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 GracefulEnable 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 *fasthttp.RequestCtx) (int, error)
Middleware must process all incoming requests before defined views.