Documentation ¶
Index ¶
- Constants
- Variables
- func Basic() lion.Middlewares
- func Classic() lion.Middlewares
- func JWTEnsureAuthenticated(contextKey interface{}) lion.Middleware
- func NewLogger() lion.Middleware
- func NewNoCache() lion.Middleware
- func NewRealIP() lion.Middleware
- func NewRecovery() lion.Middleware
- func NewStatic(directory http.FileSystem) lion.Middleware
- type JWT
- type Logger
- type MaxAge
- type NoCache
- type RealIP
- type Recovery
- type RequestID
- type ResponseWriter
- type Static
Constants ¶
const CtxRequestIDKey ctxRequestIDKeyType = 0
Variables ¶
var (
DefaultJWTContextKey = "user"
)
Functions ¶
func Basic ¶
func Basic() lion.Middlewares
func Classic ¶
func Classic() lion.Middlewares
Classic creates a new router instance with default middlewares: Recovery, RealIP, Logger. The static middleware instance is initiated with a directory named "public" located relatively to the current working directory.
func JWTEnsureAuthenticated ¶
func JWTEnsureAuthenticated(contextKey interface{}) lion.Middleware
func NewNoCache ¶
func NewNoCache() lion.Middleware
NoCache middleware sets headers to disable browser caching. Inspired by https://github.com/mytrile/nocache
func NewRealIP ¶
func NewRealIP() lion.Middleware
func NewStatic ¶
func NewStatic(directory http.FileSystem) lion.Middleware
NewStatic returns a new instance of Static
Types ¶
type JWT ¶
type JWT struct { SigningKey interface{} SigningMethod string ContextKey interface{} }
func (*JWT) EnsureAuthenticated ¶
func (j *JWT) EnsureAuthenticated() lion.Middleware
type Logger ¶
Logger is a middlewares that logs incoming http requests
type RealIP ¶
type RealIP struct{}
RealIP is a middleware that sets a http.Request's RemoteAddr to the results of parsing either the X-Forwarded-For header or the X-Real-IP header (in that order).
This middleware should be inserted fairly early in the middleware stack to ensure that subsequent layers (e.g., request loggers) which examine the RemoteAddr will see the intended value.
You should only use this middleware if you can trust the headers passed to you (in particular, the two headers this middleware uses), for example because you have placed a reverse proxy like HAProxy or nginx in front of Goji. If your reverse proxies are configured to pass along arbitrary header values from the client, or if you use this middleware without a reverse proxy, malicious clients will be able to make you very sad (or, depending on how you're using RemoteAddr, vulnerable to an attack of some sort). Taken from https://github.com/zenazn/goji/blob/master/web/middleware/realip.go
type Recovery ¶
Recovery is a middleware that recovers from panics Taken from https://github.com/codegangsta/negroni/blob/master/recovery.go
type RequestID ¶
type RequestID struct { SetHeader bool // contains filtered or unexported fields }
func NewRequestID ¶
func NewRequestID() *RequestID
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter http.Flusher http.Hijacker Status() int BytesWritten() int Tee(io.Writer) Unwrap() http.ResponseWriter }
ResponseWriter is the proxy responseWriter
type Static ¶
type Static struct { // Dir is the directory to serve static files from Dir http.FileSystem // Prefix is the optional prefix used to serve the static directory content Prefix string // IndexFile defines which file to serve as index if it exists. IndexFile string }
Static is a middleware handler that serves static files in the given directory/filesystem. Taken from https://github.com/codegangsta/negroni/blob/master/static.go