Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultSkipper(c *Context) bool
- func Fresh(reqHeader http.Header, resHeader http.Header) bool
- func GetClientIP(req *http.Request) string
- func GetContextValue[T any](c *Context, key any) T
- func GetRealIP(req *http.Request) string
- func GetRemoteAddr(req *http.Request) string
- func IsIntranet(s string) bool
- func ReadAllInitCap(r io.Reader, initCap int) ([]byte, error)
- func ReadAllToBuffer(r io.Reader, buffer *bytes.Buffer) error
- type AtomicSignedKeys
- type BeforeListener
- type BufferPool
- type Context
- func (c *Context) AddCookie(cookie *http.Cookie)
- func (c *Context) AddHeader(key, value string)
- func (c *Context) AddRequestHeader(key, value string)
- func (c *Context) AddSignedCookie(cookie *http.Cookie)
- func (c *Context) CacheMaxAge(age time.Duration, sMaxAge ...time.Duration)
- func (c *Context) ClientIP() string
- func (c *Context) Context() context.Context
- func (c *Context) Cookie(name string) (*http.Cookie, error)
- func (c *Context) Created(body any)
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) DisableReuse()
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Elton() *Elton
- func (c *Context) Err() error
- func (c *Context) Get(key any) (any, bool)
- func (c *Context) GetHeader(key string) string
- func (c *Context) GetRequestHeader(key string) string
- func (c *Context) HTML(html string)
- func (c *Context) Header() http.Header
- func (c *Context) IsReaderBody() bool
- func (c *Context) MergeHeader(h http.Header)
- func (c *Context) NewTrace() *Trace
- func (c *Context) NoCache()
- func (c *Context) NoContent()
- func (c *Context) NoStore()
- func (c *Context) NotModified()
- func (c *Context) Param(name string) string
- func (c *Context) Pass(another *Elton)
- func (c *Context) Pipe(r io.Reader) (int64, error)
- func (c *Context) PrivateCacheMaxAge(age time.Duration)
- func (c *Context) Query() map[string]string
- func (c *Context) QueryParam(name string) string
- func (c *Context) ReadFormFile(key string) ([]byte, *multipart.FileHeader, error)
- func (c *Context) RealIP() string
- func (c *Context) Redirect(code int, url string) error
- func (c *Context) RemoteAddr() string
- func (c *Context) Reset()
- func (c *Context) ResetHeader()
- func (c *Context) SendFile(file string) error
- func (c *Context) ServerTiming(traceInfos TraceInfos, prefix string)
- func (c *Context) Set(key, value any)
- func (c *Context) SetContentTypeByExt(file string)
- func (c *Context) SetHeader(key, value string)
- func (c *Context) SetRequestHeader(key, value string)
- func (c *Context) SignedCookie(name string) (*http.Cookie, error)
- func (c *Context) SignedCookieWithIndex(name string) (*http.Cookie, int, error)
- func (c *Context) Trace() *Trace
- func (c *Context) Value(key any) any
- func (c *Context) WithContext(ctx context.Context) *Context
- func (c *Context) Write(buf []byte) (int, error)
- func (c *Context) WriteHeader(statusCode int)
- type ContextKey
- type DoneListener
- type Elton
- func (e *Elton) ALL(path string, handlerList ...Handler) *Elton
- func (e *Elton) AddGroup(groups ...*Group) *Elton
- func (e *Elton) Close() error
- func (e *Elton) Closing() bool
- func (e *Elton) DELETE(path string, handlerList ...Handler) *Elton
- func (e *Elton) EmitError(c *Context, err error) *Elton
- func (e *Elton) EmitTrace(c *Context, infos TraceInfos) *Elton
- func (e *Elton) GET(path string, handlerList ...Handler) *Elton
- func (e *Elton) GetFunctionName(fn any) string
- func (e *Elton) GracefulClose(ctx context.Context, delay time.Duration) error
- func (e *Elton) HEAD(path string, handlerList ...Handler) *Elton
- func (e *Elton) Handle(method, path string, handlerList ...Handler) *Elton
- func (e *Elton) ListenAndServe(addr string) error
- func (e *Elton) ListenAndServeTLS(addr, certFile, keyFile string) error
- func (e *Elton) Multi(methods []string, path string, handlerList ...Handler) *Elton
- func (e *Elton) OPTIONS(path string, handlerList ...Handler) *Elton
- func (e *Elton) OnBefore(ln BeforeListener) *Elton
- func (e *Elton) OnDone(ln DoneListener) *Elton
- func (e *Elton) OnError(ln ErrorListener) *Elton
- func (e *Elton) OnTrace(ln TraceListener) *Elton
- func (e *Elton) PATCH(path string, handlerList ...Handler) *Elton
- func (e *Elton) POST(path string, handlerList ...Handler) *Elton
- func (e *Elton) PUT(path string, handlerList ...Handler) *Elton
- func (e *Elton) Pre(handlerList ...PreHandler) *Elton
- func (e *Elton) Routers() []RouterInfo
- func (e *Elton) Running() bool
- func (e *Elton) Serve(l net.Listener) error
- func (e *Elton) ServeHTTP(resp http.ResponseWriter, req *http.Request)
- func (e *Elton) SetFunctionName(fn any, name string)
- func (e *Elton) Shutdown(ctx context.Context) error
- func (e *Elton) Status() Status
- func (e *Elton) TRACE(path string, handlerList ...Handler) *Elton
- func (e *Elton) Use(handlerList ...Handler) *Elton
- func (e *Elton) UseWithName(handler Handler, name string) *Elton
- type ErrorHandler
- type ErrorListener
- type GenerateID
- type Group
- func (g *Group) ALL(path string, handlerList ...Handler) *Group
- func (g *Group) DELETE(path string, handlerList ...Handler) *Group
- func (g *Group) GET(path string, handlerList ...Handler) *Group
- func (g *Group) HEAD(path string, handlerList ...Handler) *Group
- func (g *Group) Multi(methods []string, path string, handlerList ...Handler) *Group
- func (g *Group) NewGroup(path string, handlerList ...Handler) *Group
- func (g *Group) OPTIONS(path string, handlerList ...Handler) *Group
- func (g *Group) PATCH(path string, handlerList ...Handler) *Group
- func (g *Group) POST(path string, handlerList ...Handler) *Group
- func (g *Group) PUT(path string, handlerList ...Handler) *Group
- func (g *Group) TRACE(path string, handlerList ...Handler) *Group
- type HTMLTemplate
- type Handler
- type MultipartForm
- type PreHandler
- type RWMutexSignedKeys
- type ReadFile
- type RouteParams
- type Router
- type RouterInfo
- type SignedKeysGenerator
- type SimpleSignedKeys
- type Skipper
- type Status
- type TemplateParser
- type TemplateParsers
- type Trace
- type TraceInfo
- type TraceInfos
- type TraceListener
Constants ¶
const ( // ErrCategory elton category ErrCategory = "elton" // HeaderXForwardedFor x-forwarded-for HeaderXForwardedFor = "X-Forwarded-For" // HeaderXRealIP x-real-ip HeaderXRealIP = "X-Real-Ip" // HeaderSetCookie Set-Cookie HeaderSetCookie = "Set-Cookie" // HeaderLocation Location HeaderLocation = "Location" // HeaderContentType Content-Type HeaderContentType = "Content-Type" // HeaderAuthorization Authorization HeaderAuthorization = "Authorization" // HeaderWWWAuthenticate WWW-Authenticate HeaderWWWAuthenticate = "WWW-Authenticate" // HeaderCacheControl Cache-Control HeaderCacheControl = "Cache-Control" // HeaderETag ETag HeaderETag = "ETag" // HeaderLastModified last modified HeaderLastModified = "Last-Modified" // HeaderContentEncoding content encoding HeaderContentEncoding = "Content-Encoding" // HeaderContentLength content length HeaderContentLength = "Content-Length" // HeaderIfModifiedSince if modified since HeaderIfModifiedSince = "If-Modified-Since" // HeaderIfNoneMatch if none match HeaderIfNoneMatch = "If-None-Match" // HeaderAcceptEncoding accept encoding HeaderAcceptEncoding = "Accept-Encoding" // HeaderServerTiming server timing HeaderServerTiming = "Server-Timing" // HeaderTransferEncoding transfer encoding HeaderTransferEncoding = "Transfer-Encoding" // MinRedirectCode min redirect code MinRedirectCode = 300 // MaxRedirectCode max redirect code MaxRedirectCode = 308 // MIMETextPlain text plain MIMETextPlain = "text/plain; charset=utf-8" // MIMEApplicationJSON application json MIMEApplicationJSON = "application/json; charset=utf-8" // MIMEBinary binary data MIMEBinary = "application/octet-stream" // Gzip gzip compress Gzip = "gzip" // Br brotli compress Br = "br" // Zstd zstd compress Zstd = "zstd" )
const (
// SignedCookieSuffix signed cookie suffix
SignedCookieSuffix = ".sig"
)
Variables ¶
var ( // ErrInvalidRedirect invalid redirect ErrInvalidRedirect = &hes.Error{ StatusCode: 400, Message: "invalid redirect", Category: ErrCategory, } // ErrFileNotFound file not found ErrFileNotFound = &hes.Error{ StatusCode: 404, Message: "file not found", Category: ErrCategory, } )
var ( // ServerTimingDur server timing dur ServerTimingDur = []byte(";dur=") // ServerTimingDesc server timing desc ServerTimingDesc = []byte(`;desc="`) // ServerTimingEnd server timing end ServerTimingEnd = []byte(`"`) )
var DefaultTemplateParsers = NewTemplateParsers()
var ErrServerNotInitialized = errors.New("server is not initialized")
ErrServerNotInitialized the http server of elton is not initialized
var (
ErrSignKeyIsNil = hes.New("keys for sign cookie can't be nil")
)
Functions ¶
func GetClientIP ¶
GetClientIP returns the client ip of request, it will get ip from x-forwarded-for from request header and get the first public ip, if not exists then it will get ip from x-real-ip from request header, if not exists then it will use remote addr.
func GetContextValue ¶
GetContextValue returns the value of the key from the context store. The zero value of T will be returned if the key does not exist or the value doesn't match type T.
func GetRealIP ¶
GetRealIP returns the real ip of request, it will get ip from x-forwarded-for from request header, if not exists then it will get ip from x-real-ip from request header, if not exists then it will use remote addr.
func GetRemoteAddr ¶
GetRemoteAddr returns the remote addr of request
func IsIntranet ¶
IsIntranet reports whether s is a loopback, private, or link-local address. Invalid or empty values return false.
func ReadAllInitCap ¶
copy from io.ReadAll ReadAll reads from r until an error or EOF and returns the data it read. A successful call returns err == nil, not err == EOF. Because ReadAll is defined to read from src until EOF, it does not treat an EOF from Read as an error to be reported.
Types ¶
type AtomicSignedKeys ¶
type AtomicSignedKeys struct {
// contains filtered or unexported fields
}
AtomicSignedKeys atomic toggle signed keys
func (*AtomicSignedKeys) Keys ¶
func (atSk *AtomicSignedKeys) Keys() []string
Keys returns the key list of atomic signed keys
func (*AtomicSignedKeys) SetKeys ¶
func (atSk *AtomicSignedKeys) SetKeys(values []string)
SetKeys sets the key list of atomic signed keys
type BeforeListener ¶
type BeforeListener func(*Context)
BeforeListener before request handle listener
type BufferPool ¶
A BufferPool is an interface for getting and returning temporary buffer
func NewBufferPool ¶
func NewBufferPool(initCap int) BufferPool
NewBufferPool creates a buffer pool, if the init cap gt 0, the buffer will be init with cap size
type Context ¶
type Context struct {
Request *http.Request
Response http.ResponseWriter
// Committed commit the data to response, when it's true, the response has been sent.
// If using custom response handler, please set it true.
Committed bool
// ID context id, using unique string function to generate it.
ID string
// Route route path, it's equal to the http router path with params.
Route string
// Next advances the middleware/handler chain. Set by the framework (stable boundNext);
// Compose may temporarily replace it. Prefer calling Next() rather than reassigning.
Next func() error
// Params route params
Params *RouteParams
// StatusCode http response's status code, default is 0 which will be handle as 200
StatusCode int
// Body http response's body, which should be converted to bytes by responder middleware.
// JSON response middleware, xml response middleware and so on.
// 约定:io.Reader类型的Body由框架流式写出(实现io.Closer会被自动关闭);
// 其它类型需由responder等中间件转换为BodyBuffer后输出
Body any
// BodyBuffer http response's body buffer, it should be set by responder middleware.
BodyBuffer *bytes.Buffer
// RequestBody http request body, which should be converted by request body parser middleware.
RequestBody []byte
// contains filtered or unexported fields
}
Context elton context
func NewContext ¶
func NewContext(resp http.ResponseWriter, req *http.Request) *Context
NewContext return a new context
func (*Context) AddHeader ¶
AddHeader adds the key/value to response header. It appends to any existing value of the key.
func (*Context) AddRequestHeader ¶
AddRequestHeader adds the key/value to http header. It appends to any existing value of the key.
func (*Context) AddSignedCookie ¶
AddSignedCookie adds cookie to the response, it will also add a signed cookie
func (*Context) CacheMaxAge ¶
CacheMaxAge sets `Cache-Control: public, max-age=MaxAge, s-maxage=SMaxAge` to the http response header. If sMaxAge is not empty, it will use the first duration as SMaxAge
func (*Context) ClientIP ¶
ClientIP returns the client ip of request, it will get ip from x-forwared-for from request header and get the first public ip, if not exists then it will get ip from x-real-ip from request header, if not exists then it will use remote addr.
func (*Context) DisableReuse ¶
func (c *Context) DisableReuse()
DisableReuse sets the context disable reuse
func (*Context) GetHeader ¶
GetHeader returns header value from http response. Note: unqualified header methods (GetHeader/SetHeader/AddHeader) operate on the RESPONSE header, use GetRequestHeader to read the request header
func (*Context) GetRequestHeader ¶
GetRequestHeader returns header value from http request
func (*Context) IsReaderBody ¶
IsReaderBody judgets whether body is reader
func (*Context) MergeHeader ¶
MergeHeader merges http header to response header
func (*Context) NoCache ¶
func (c *Context) NoCache()
NoCache sets `Cache-Control: no-cache` to the http response header
func (*Context) NoContent ¶
func (c *Context) NoContent()
NoContent clean all content and set status to 204
func (*Context) NoStore ¶
func (c *Context) NoStore()
NoStore sets `Cache-Control: no-store` to the http response header
func (*Context) NotModified ¶
func (c *Context) NotModified()
NotModified clean all content and set status to 304
func (*Context) Param ¶
Param returns the route param value. Prefer Request.PathValue (ServeMux); fall back to Params for manual/test setups.
func (*Context) PrivateCacheMaxAge ¶
PrivateCacheMaxAge sets `Cache-Control: private, max-age=MaxAge` to the response header.
func (*Context) Query ¶
Query returns the query map. It will return map[string]string, not the same as url.Values If want to get url.Values, use c.Request.URL.Query()
func (*Context) QueryParam ¶
QueryParam returns the query param value
func (*Context) ReadFormFile ¶
ReadFormFile reads the multipart form file data from request
func (*Context) RealIP ¶
RealIP returns the real ip of request, it will get ip from x-forwarded-for from request header, if not exists then it will get ip from x-real-ip from request header, if not exists then it will use remote addr.
func (*Context) RemoteAddr ¶
RemoteAddr returns the remote addr of request
func (*Context) ServerTiming ¶
func (c *Context) ServerTiming(traceInfos TraceInfos, prefix string)
ServerTiming converts trace info to http response server timing
func (*Context) SetContentTypeByExt ¶
SetContentTypeByExt sets content type by file extname
func (*Context) SetHeader ¶
SetHeader sets the key/value to response header. It replaces any existing values of the key.
func (*Context) SetRequestHeader ¶
SetRequestHeader sets http header to request. It replaces any existing values of the key.
func (*Context) SignedCookie ¶
SignedCookie returns signed cookie from http request
func (*Context) SignedCookieWithIndex ¶
SignedCookieWithIndex returns signed cookie from http request
func (*Context) Trace ¶
Trace gets trace from context, if context without trace, new trace will be created.
func (*Context) WithContext ¶
WithContext changes the request to new request with context
func (*Context) WriteHeader ¶
WriteHeader sets the http status code
type Elton ¶
type Elton struct {
// Server http server
Server *http.Server
// ErrorHandler set the function for error handler
ErrorHandler ErrorHandler
// NotFoundHandler set the function for not found handler
NotFoundHandler http.HandlerFunc
// MethodNotAllowedHandler set the function for method not allowed handler
MethodNotAllowedHandler http.HandlerFunc
// GenerateID generate id function, will use it to create context's id
GenerateID GenerateID
// EnableTrace enable trace
EnableTrace bool
// SignedKeys signed keys
SignedKeys SignedKeysGenerator
// contains filtered or unexported fields
}
Elton web framework instance
func NewWithoutServer ¶
func NewWithoutServer() *Elton
NewWithoutServer returns a new elton instance without http server
func (*Elton) EmitError ¶
EmitError emits an error event, it will call the listen functions of error event
func (*Elton) EmitTrace ¶
func (e *Elton) EmitTrace(c *Context, infos TraceInfos) *Elton
EmitTrace emits a trace event, it will call the listen functions of trace event
func (*Elton) GetFunctionName ¶
GetFunctionName return the name of handler function
func (*Elton) GracefulClose ¶
GracefulClose closes the http server gracefully. It sets the status to be closing (rejecting new requests with 503), waits for the delay, then shuts down the server. ctx取消时停止等待并立即进入shutdown(此时Shutdown会关闭监听 并立即返回ctx.Err,不再等待活跃连接处理完成)。
func (*Elton) Handle ¶
Handle adds http handle function. 注册时将当时的全局中间件(Use)与该路由 handler 快照合并为一条固定执行链; 请求到达时通过 c.Next() 推进(洋葱模型),Next 使用 Context 上复用的 boundNext, 避免每请求分配闭包:
- 任一环节返回 error 则中断,触发 error 监听器并输出错误响应;
- c.Committed 为 true 时 Next 短路,不再执行后续 handler;
- 链执行完成后,统一将 BodyBuffer(或 reader 类型的 Body)写出至响应。
path 使用 net/http ServeMux 模式(Go 1.22+):{name}、{name...}、{$}; 仍兼容段首 :name 与末尾 /*(分别转为 {name}、{path...})。 注册 pattern 为 "METHOD path";冲突的 pattern 会 panic(标准库行为)。
注意:应在 Listen 前完成 Use + 路由注册。某路由注册之后再 Use 的中间件 不会作用于该路由(链在 Handle 时已快照)。
func (*Elton) ListenAndServe ¶
ListenAndServe listens the addr and serve http, it returns ErrServerNotInitialized if the server of elton is nil.
func (*Elton) ListenAndServeTLS ¶
ListenAndServeTLS listens the addr and serve https, it returns ErrServerNotInitialized if the server of elton is nil.
func (*Elton) OnBefore ¶
func (e *Elton) OnBefore(ln BeforeListener) *Elton
OnBefore adds listen to before request done(after pre middlewares, before middlewares)
func (*Elton) OnDone ¶
func (e *Elton) OnDone(ln DoneListener) *Elton
OnDone adds listen to request done, it will be triggered when the request handle is done
func (*Elton) OnError ¶
func (e *Elton) OnError(ln ErrorListener) *Elton
OnError adds listen to error event
func (*Elton) OnTrace ¶
func (e *Elton) OnTrace(ln TraceListener) *Elton
OnTrace adds listen to trace event
func (*Elton) Pre ¶
func (e *Elton) Pre(handlerList ...PreHandler) *Elton
Pre adds pre middleware function handler to elton's pre middleware list
func (*Elton) Serve ¶
Serve serves http server, it returns ErrServerNotInitialized if the server of elton is nil.
func (*Elton) ServeHTTP ¶
func (e *Elton) ServeHTTP(resp http.ResponseWriter, req *http.Request)
ServeHTTP http handler
func (*Elton) SetFunctionName ¶
SetFunctionName sets the name of handler function, it will use to http timing
func (*Elton) Shutdown ¶
Shutdown gracefully shuts down the http server without interrupting any active connections
type Group ¶
Group group router
func (*Group) NewGroup ¶
NewGroup returns a new sub group of the group, the path and handler list will be merged with the parent's. The sub group will be added to elton together with its parent by elton.AddGroup.
type HTMLTemplate ¶
type HTMLTemplate struct {
// contains filtered or unexported fields
}
func NewHTMLTemplate ¶
func NewHTMLTemplate(read ReadFile) *HTMLTemplate
func (*HTMLTemplate) RenderFile ¶
Render renders the text of file using text/template
type MultipartForm ¶
type MultipartForm struct {
// contains filtered or unexported fields
}
func NewMultipartForm ¶
func NewMultipartForm() *MultipartForm
NewMultipartForm returns a new multipart form, the form data will be saved as tmp file for less memory.
func (*MultipartForm) AddField ¶
func (f *MultipartForm) AddField(name, value string) error
AddField adds a field to form
func (*MultipartForm) AddFile ¶
func (f *MultipartForm) AddFile(name, filename string, reader ...io.Reader) error
AddFile add a file to form, if the reader is nil, the filename will be used to open as reader
func (*MultipartForm) Close ¶
func (f *MultipartForm) Close() error
Close closes the writer and removes the tmpfile
func (*MultipartForm) ContentType ¶
func (f *MultipartForm) ContentType() string
ContentType returns the content type of form
type RWMutexSignedKeys ¶
RWMutexSignedKeys read/write mutex signed key
func (*RWMutexSignedKeys) Keys ¶
func (rwSk *RWMutexSignedKeys) Keys() []string
Keys returns the key list of rwmutex signed keys
func (*RWMutexSignedKeys) SetKeys ¶
func (rwSk *RWMutexSignedKeys) SetKeys(values []string)
SetKeys sets the key list of rwmutex signed keys
type RouteParams ¶
type RouteParams struct {
Keys, Values []string
}
RouteParams tracks URL path wildcards for a request. Values are filled from http.Request.PathValue after ServeMux matches a route.
func (*RouteParams) Add ¶
func (s *RouteParams) Add(key, value string)
Add appends a path parameter.
func (*RouteParams) Get ¶
func (s *RouteParams) Get(key string) string
Get returns the value for key, or "" if missing.
func (*RouteParams) Reset ¶
func (s *RouteParams) Reset()
Reset clears all parameters for pool reuse.
func (*RouteParams) ToMap ¶
func (s *RouteParams) ToMap() map[string]string
ToMap converts route params to map[string]string.
type Router ¶
type Router struct {
Method string `json:"method,omitempty"`
Path string `json:"path,omitempty"`
HandleList []Handler `json:"-"`
}
Router router
type RouterInfo ¶
type RouterInfo struct {
Method string `json:"method,omitempty"`
Route string `json:"route,omitempty"`
}
RouterInfo router's info
type SignedKeysGenerator ¶
SignedKeysGenerator signed keys generator
type SimpleSignedKeys ¶
type SimpleSignedKeys struct {
// contains filtered or unexported fields
}
SimpleSignedKeys simple sigined key
func (*SimpleSignedKeys) Keys ¶
func (sk *SimpleSignedKeys) Keys() []string
Keys returns the key list of simple signed keys
func (*SimpleSignedKeys) SetKeys ¶
func (sk *SimpleSignedKeys) SetKeys(values []string)
SetKeys sets the key list of simple signed keys
type TemplateParser ¶
type TemplateParsers ¶
type TemplateParsers map[string]TemplateParser
func NewTemplateParsers ¶
func NewTemplateParsers() TemplateParsers
func (TemplateParsers) Add ¶
func (tps TemplateParsers) Add(template string, parser TemplateParser)
func (TemplateParsers) Get ¶
func (tps TemplateParsers) Get(template string) TemplateParser
type Trace ¶
type Trace struct {
Infos TraceInfos
// contains filtered or unexported fields
}
func TraceFromContext ¶
TraceFromContext gets trace from context, if context without trace, new trace will be created.
type TraceInfo ¶
type TraceInfo struct {
Middleware bool `json:"-"`
Name string `json:"name,omitempty"`
Duration time.Duration `json:"duration,omitempty"`
}
TraceInfo trace's info
type TraceInfos ¶
type TraceInfos []*TraceInfo
TraceInfos trace infos
func (TraceInfos) Filter ¶
func (traceInfos TraceInfos) Filter(fn func(*TraceInfo) bool) TraceInfos
Filter filters the trace info, the new trace infos will be returned.
func (TraceInfos) FilterDurationGreaterThan ¶
func (traceInfos TraceInfos) FilterDurationGreaterThan(d time.Duration) TraceInfos
FilterDurationGreaterThan filters the trace infos of which duration is greater than d.
func (TraceInfos) ServerTiming ¶
func (traceInfos TraceInfos) ServerTiming(prefix string) string
ServerTiming return server timing with prefix
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
api
command
API example: Recommended + CORS + Timeout + nested groups.
|
API example: Recommended + CORS + Timeout + nested groups. |
|
hello
command
Hello example: Recommended middleware stack + simple JSON routes.
|
Hello example: Recommended middleware stack + simple JSON routes. |
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |