Documentation ¶
Index ¶
Constants ¶
const (
// NoPrintStackBodyString is the body content returned when HTTP stack printing is suppressed
NoPrintStackBodyString = "500 Internal Server Error"
)
Variables ¶
var LoggerDefaultDateFormat = "2006/01/02 - 15:04:05.00"
var LoggerDefaultFormat = "{{.StartTime}} | {{.Status}} \t {{.Duration}} | {{.HostName}} | {{.Method}} | {{.Path}} "
Functions ¶
This section is empty.
Types ¶
type ALogger ¶
type ALogger interface { Println(v ...interface{}) Printf(format string, v ...interface{}) }
type HTMLPanicFormatter ¶
type HTMLPanicFormatter struct{}
HTMLPanicFormatter output the stack inside an HTML page. This has been largely inspired by https://github.com/go-martini/martini/pull/156/commits.
func (*HTMLPanicFormatter) FormatPanicError ¶
func (t *HTMLPanicFormatter) FormatPanicError(rw http.ResponseWriter, r *http.Request, infos *PanicInformation)
type Logger ¶
type Logger struct { ALogger ALogger // contains filtered or unexported fields }
func (*Logger) Inovke ¶
func (l *Logger) Inovke(ctx *Context.HttpContext, next func(ctx *Context.HttpContext))
func (*Logger) SetDateFormat ¶
type LoggerInfo ¶
type LoggerInfo struct { StartTime string Status int Duration string HostName string Method string Path string Body string Request *http.Request }
func (*LoggerInfo) MethodColor ¶
func (p *LoggerInfo) MethodColor() string
MethodColor is the ANSI color for appropriately logging http method to a terminal.
func (*LoggerInfo) ResetColor ¶
func (p *LoggerInfo) ResetColor() string
ResetColor resets all escape attributes.
func (*LoggerInfo) StatusCodeColor ¶
func (p *LoggerInfo) StatusCodeColor() string
StatusCodeColor is the ANSI color for appropriately logging http status code to a terminal.
type PanicFormatter ¶
type PanicFormatter interface { // FormatPanicError output the stack for a given answer/response. // In case the the middleware should not output the stack trace, // the field `Stack` of the passed `PanicInformation` instance equals `[]byte{}`. FormatPanicError(rw http.ResponseWriter, r *http.Request, infos *PanicInformation) }
PanicFormatter is an interface on object can implement to be able to output the stack trace
type PanicInformation ¶
PanicInformation contains all elements for printing stack informations.
func (*PanicInformation) RequestDescription ¶
func (p *PanicInformation) RequestDescription() string
RequestDescription returns a printable description of the url
func (*PanicInformation) StackAsString ¶
func (p *PanicInformation) StackAsString() string
StackAsString returns a printable version of the stack
type Recovery ¶
type Recovery struct { Logger ALogger PrintStack bool LogStack bool PanicHandlerFunc func(*PanicInformation) StackAll bool StackSize int Formatter PanicFormatter }
func (*Recovery) Inovke ¶
func (rec *Recovery) Inovke(ctx *Context.HttpContext, next func(ctx *Context.HttpContext))
type RouterMiddleware ¶
type RouterMiddleware struct {
RouterBuilder Router.IRouterBuilder
}
func NewRouter ¶
func NewRouter(builder Router.IRouterBuilder) *RouterMiddleware
func (*RouterMiddleware) Inovke ¶
func (router *RouterMiddleware) Inovke(ctx *Context.HttpContext, next func(ctx *Context.HttpContext))
type Static ¶
func (*Static) Inovke ¶
func (s *Static) Inovke(ctx *Context.HttpContext, next func(ctx *Context.HttpContext))
type TextPanicFormatter ¶
type TextPanicFormatter struct{}
TextPanicFormatter output the stack as simple text on os.Stdout. If no `Content-Type` is set, it will output the data as `text/plain; charset=utf-8`. Otherwise, the origin `Content-Type` is kept.
func (*TextPanicFormatter) FormatPanicError ¶
func (t *TextPanicFormatter) FormatPanicError(rw http.ResponseWriter, r *http.Request, infos *PanicInformation)