Documentation ¶
Index ¶
- func Abbreviate(str string, maxWidth int) string
- func AnyPrefix(s string, prefixes ...string) bool
- func At(s []string, i int) string
- func GetRemoteAddress(r *http.Request) string
- func IPAddrFromRemoteAddr(s string) string
- func If(b bool, s1, s2 string) string
- func IsWsRequest(url string) bool
- func PeekBody(r *http.Request, maxSize int) []byte
- func PutAttr(c *gin.Context, key string, value interface{})
- func PutAttrMap(c *gin.Context, attrs map[string]interface{})
- type Adapter
- func (a *Adapter) Adapt(relativePath string, argV interface{}) adapt.Handler
- func (a *Adapter) Biz(biz string) OptionFn
- func (a *Adapter) Default(relativePath string) adapt.Handler
- func (a *Adapter) F(fns ...OptionFn) adapt.Parent
- func (a *Adapter) Ignore() OptionFn
- func (a *Adapter) MaxSize(v int) OptionFn
- func (a *Adapter) Tables(tables ...string) OptionFn
- type Attrs
- type Log
- type LogrusStore
- type Middle
- type Option
- type OptionFn
- type SQLStore
- type Store
- type Stores
- type TableCol
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Abbreviate ¶
Abbreviate abbreviates a string using ellipses.
func GetRemoteAddress ¶
GetRemoteAddress returns ip address of the client making the request, taking into account http proxies.
func IPAddrFromRemoteAddr ¶
IPAddrFromRemoteAddr parses the IP Address. Request.RemoteAddress contains port, which we want to remove i.e.: "[::1]:58292" => "[::1]".
func IsWsRequest ¶
IsWsRequest return true if this request is a websocket request.
func PutAttrMap ¶
PutAttrMap put an attribute map into the Attributes in the context.
Types ¶
type Attrs ¶
type Attrs map[string]interface{}
Attrs carries map. It implements value for that key and delegates all other calls to the embedded Context.
type Log ¶
type Log struct { ID string Biz string // Method is GET etc. Method string URL string IPAddr string RspHeader http.Header ReqBody string // RspStatus, like 200, 404. RspStatus int // ReqHeader records the response header. ReqHeader http.Header // RespSize is number of bytes of the response sent. RespSize int // RspBody is the response body(limit to 1000). RspBody string Created time.Time // Start records the start time of the request. Start time.Time // End records the end time of the request. End time.Time // Duration means how long did it take to. Duration time.Duration Attrs Attrs Option *Option PathParams gin.Params Request *http.Request }
Log describes info about HTTP request.
type SQLStore ¶
SQLStore stores the log into database.
func NewSQLStore ¶
NewSQLStore creates a new SQLStore.
type Store ¶
type Store interface { // Store stores the log in database like MySQL, InfluxDB, and etc. Store(c *gin.Context, log *Log) }
Store defines the interface to Store a log.
type TableCol ¶
type TableCol struct { Name string `name:"column_name"` Comment string `name:"column_comment"` DataType string `name:"data_type"` Extra string `name:"extra"` Nullable string `name:"nullable"` MaxLength int `name:"max_length"` ValueGetter col `name:"-"` }
TableCol defines the schema of a table.