middleware

package
v0.0.0-...-f0d5876 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogTimeFormat     = "01/Jan/2006:15:04:05 -0700"
	RequestContextKey = "github.com/pshgo/cmd/serve/middleware/RequestContextKey"
)
View Source
const (
	LogContextKey = "github.com/demosdemon/pshgo/cmd/serve/middleware/LogContextKey"
)

Variables

Functions

func HandlePanic

func HandlePanic(c lars.Context, p *cpanic.Panic)

func Log

func Log(c lars.Context)

func NewRequest

func NewRequest(c lars.Context)

func Recover

func Recover(c lars.Context)

Types

type LogContext

type LogContext interface {
	Log() Logger
}

type Logger

type Logger = *logrus.Entry

type PanicHandler

type PanicHandler interface {
	HandlePanic(p *cpanic.Panic)
}

type Request

type Request struct {
	Start      time.Time         `json:"start"`
	ID         string            `json:"id"`
	Username   string            `json:"username,omitempty"`
	ClientIP   string            `json:"client_ip"`
	RemoteAddr string            `json:"remote_addr"`
	Method     string            `json:"method"`
	URL        string            `json:"url"`
	Proto      string            `json:"proto"`
	Referrer   string            `json:"referrer,omitempty"`
	UserAgent  string            `json:"user_agent"`
	Host       string            `json:"host"`
	Headers    map[string]string `json:"headers"`
	Delay      pshgo.Duration    `json:"delay,omitempty"`
	Status     int               `json:"status,omitempty"`
	Size       int64             `json:"size,omitempty"`
	Panic      *cpanic.Panic     `json:"panic,omitempty"`
}

func (Request) Fields

func (r Request) Fields() logrus.Fields

func (Request) String

func (r Request) String() string

func (*Request) UpdateLARS

func (r *Request) UpdateLARS(res *lars.Response)

Update returns a new Request object with fields updated from the lars response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL