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 ¶
- Variables
- func B2S(b []byte) string
- func HTTPResponse(ctx *fasthttp.RequestCtx, response []byte, statusCode ...int) error
- func JSONResponse(ctx *fasthttp.RequestCtx, response interface{}, statusCode ...int) error
- func RedirectResponse(ctx *fasthttp.RequestCtx, url string, statusCode int) error
- type Atreugo
- type Config
- type JSON
- type Middleware
- type View
Constants ¶
This section is empty.
Variables ¶
var AllowedHTTPMethods = []string{"GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH", "DELETE"}
AllowedHTTPMethods all http methods that Atruego supports
Functions ¶
func HTTPResponse ¶
func HTTPResponse(ctx *fasthttp.RequestCtx, response []byte, statusCode ...int) error
HTTPResponse return http response with content-type text/html; charset=utf-8
func JSONResponse ¶
func JSONResponse(ctx *fasthttp.RequestCtx, response interface{}, statusCode ...int) error
JSONResponse return http response with content-type application/json
func RedirectResponse ¶
func RedirectResponse(ctx *fasthttp.RequestCtx, url string, statusCode int) error
RedirectResponse redirect request to an especific url
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.