Documentation ¶
Index ¶
- Constants
- Variables
- func NewSign(uri, body, timestamp, appSecret string) string
- func PrometheusHandler() fasthttp.RequestHandler
- func VerifySign(uri, body, timestamp, appSecret, sig string, duration int64) bool
- type Authorization
- type CorsHandler
- type Logger
- type Middleware
- type Middlewares
- type Options
- type Prometheus
- type Recovery
Constants ¶
View Source
const ( SignCode = "X-Sign" SignTimestamp = "X-Sign-Timestamp" SignAppid = "X-App-Id" )
Variables ¶
View Source
var DefaultMiddlewares = Middlewares{ Handles: []Middleware{&Logger{}, &Recovery{}}, }
Functions ¶
func PrometheusHandler ¶
func PrometheusHandler() fasthttp.RequestHandler
since prometheus/client_golang use net/http we need this net/http adapter for fasthttp
func VerifySign ¶
Types ¶
type Authorization ¶
type Authorization struct {
// contains filtered or unexported fields
}
func NewAuthorization ¶
func NewAuthorization(appid, secret string, duration int64) *Authorization
func (*Authorization) Handle ¶
func (a *Authorization) Handle() func(next fasthttp.RequestHandler) fasthttp.RequestHandler
func (*Authorization) Verify ¶
func (a *Authorization) Verify(ctx *fasthttp.RequestCtx) bool
type CorsHandler ¶
type CorsHandler struct {
// contains filtered or unexported fields
}
func DefaultCorsHandler ¶
func DefaultCorsHandler() *CorsHandler
func NewCorsHandler ¶
func NewCorsHandler(options Options) *CorsHandler
func (*CorsHandler) Handle ¶
func (c *CorsHandler) Handle() func(next fasthttp.RequestHandler) fasthttp.RequestHandler
type Logger ¶
type Logger struct { }
func (*Logger) Handle ¶
func (l *Logger) Handle() func(next fasthttp.RequestHandler) fasthttp.RequestHandler
type Middleware ¶
type Middleware interface {
Handle() func(next fasthttp.RequestHandler) fasthttp.RequestHandler
}
type Middlewares ¶
type Middlewares struct {
Handles []Middleware
}
func NewMiddlewares ¶
func NewMiddlewares(middlewares ...Middleware) Middlewares
NewMiddlewares returns middlewares
func (Middlewares) Append ¶
func (m Middlewares) Append(middlewares ...Middleware) Middlewares
Append copy all middleware layers to newLayers, then append middlewares to newLayers, then return a new middleware onion.
func (Middlewares) Apply ¶
func (m Middlewares) Apply(h fasthttp.RequestHandler) fasthttp.RequestHandler
type Options ¶
type Options struct { AllowedOrigins []string AllowedHeaders []string AllowMaxAge int AllowedMethods []string ExposedHeaders []string AllowCredentials bool Debug bool }
Options is struct that defined cors properties
type Prometheus ¶
type Prometheus struct {
// contains filtered or unexported fields
}
Prometheus contains the metrics gathered by the instance and its path
func NewPrometheus ¶
func NewPrometheus(subsystem, uri string) *Prometheus
NewPrometheus generates a new set of metrics with a certain subsystem name
func (*Prometheus) Handle ¶
func (p *Prometheus) Handle() func(next fasthttp.RequestHandler) fasthttp.RequestHandler
type Recovery ¶
type Recovery struct { }
func NewRecovery ¶
func NewRecovery() *Recovery
func (*Recovery) Handle ¶
func (r *Recovery) Handle() func(next fasthttp.RequestHandler) fasthttp.RequestHandler
Click to show internal directories.
Click to hide internal directories.