Documentation
¶
Index ¶
- func AddSpanAttribute(ctx context.Context, key, value string)
- func AddSpanAttributes(ctx context.Context, attrs map[string]string)
- func AddSpanEvent(ctx context.Context, name string, attrs map[string]string)
- func CustomTracingMiddleware(tm *libTracing.TracingManager) func(http.Handler) http.Handler
- func GetSpanFromContext(ctx context.Context) trace.Span
- func NetHttpErrorHandler(path, title string, handler ContextInitiator) http.HandlerFunc
- func NetHttpHandler(handler any) http.HandlerFunc
- func RecordSpanError(ctx context.Context, err error, attrs map[string]string)
- func TracingMiddleware() func(http.Handler) http.Handler
- type ContextInitiator
- type Middleware
- type NetHttpParser
- func (c NetHttpParser) Abort() error
- func (c NetHttpParser) AddCustomAttributes(attr slog.Attr)
- func (c *NetHttpParser) AddParam(key, value string)
- func (c NetHttpParser) AddSpanAttribute(key, value string)
- func (c NetHttpParser) AddSpanAttributes(attrs map[string]string)
- func (c NetHttpParser) AddSpanEvent(name string, attrs map[string]string)
- func (c NetHttpParser) CheckUrlParam(name string) (string, bool)
- func (c NetHttpParser) FileAttachment(path, fileName string)
- func (c NetHttpParser) FormValue(name string) string
- func (c NetHttpParser) GetArgs(args ...any) map[string]string
- func (c NetHttpParser) GetBody(target any) error
- func (c NetHttpParser) GetContext() context.Context
- func (c NetHttpParser) GetCookie(name string) (*http.Cookie, error)
- func (c NetHttpParser) GetCookies() []*http.Cookie
- func (c NetHttpParser) GetFormValue(key string) string
- func (c NetHttpParser) GetFormValues(key string) []string
- func (c NetHttpParser) GetHeader(target webFramework.HeaderInterface) error
- func (c NetHttpParser) GetHeaderValue(name string) string
- func (c NetHttpParser) GetHttpHeader() http.Header
- func (c NetHttpParser) GetLocal(name string) any
- func (c NetHttpParser) GetLocalString(name string) string
- func (c NetHttpParser) GetMethod() string
- func (c NetHttpParser) GetPath() string
- func (c NetHttpParser) GetPostFormValue(key string) string
- func (c NetHttpParser) GetPostFormValues(key string) []string
- func (c NetHttpParser) GetRawUrlQuery() string
- func (c NetHttpParser) GetTraceContext() trace.SpanContext
- func (c NetHttpParser) GetUri(target any) error
- func (c NetHttpParser) GetUrlParam(name string) string
- func (c NetHttpParser) GetUrlParams() map[string]string
- func (c NetHttpParser) GetUrlQuery(target any) error
- func (c NetHttpParser) Next() error
- func (c NetHttpParser) ParseCommand(command, title string, request webFramework.RecordData, ...) string
- func (c NetHttpParser) ParseForm() error
- func (c NetHttpParser) ParseMultipartForm(maxMemory int64) error
- func (c NetHttpParser) RecordSpanError(err error, attrs map[string]string)
- func (c NetHttpParser) Redirect(url string, statusCode int)
- func (c NetHttpParser) SaveFile(formTagName, path string) error
- func (c NetHttpParser) SendJSONRespBody(status int, resp any) error
- func (c NetHttpParser) ServeContent(name string, modtime time.Time, content io.ReadSeeker)
- func (c NetHttpParser) ServeFile(name string)
- func (c NetHttpParser) SetContext(ctx context.Context)
- func (c NetHttpParser) SetCookie(cookie *http.Cookie)
- func (c NetHttpParser) SetLocal(name string, value any)
- func (c *NetHttpParser) SetParams(params map[string]string)
- func (c NetHttpParser) SetReqHeader(name string, value string)
- func (c NetHttpParser) SetRespHeader(name string, value string)
- func (c NetHttpParser) SetTraceContext(spanCtx trace.SpanContext)
- func (c NetHttpParser) StartSpan(name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSpanAttribute ¶ added in v0.18.0
AddSpanAttribute adds an attribute to the current span
func AddSpanAttributes ¶ added in v0.18.0
AddSpanAttributes adds multiple attributes to the current span
func AddSpanEvent ¶ added in v0.18.0
AddSpanEvent adds an event to the current span
func CustomTracingMiddleware ¶ added in v0.18.0
func CustomTracingMiddleware(tm *libTracing.TracingManager) func(http.Handler) http.Handler
CustomTracingMiddleware creates a custom net/http middleware with more control
func GetSpanFromContext ¶ added in v0.18.0
GetSpanFromContext gets the span from context
func NetHttpErrorHandler ¶
func NetHttpErrorHandler(path, title string, handler ContextInitiator) http.HandlerFunc
func NetHttpHandler ¶
func NetHttpHandler(handler any) http.HandlerFunc
NetHttpHandler wraps a handler function to work with net/http
func RecordSpanError ¶ added in v0.18.0
RecordSpanError records an error in the current span
Types ¶
type ContextInitiator ¶
type ContextInitiator interface {
InitContext(r *http.Request, w http.ResponseWriter) webFramework.WebFramework
Respond(int, int, string, any, bool, webFramework.WebFramework)
}
type Middleware ¶
Middleware function type for net/http
func ChainMiddleware ¶
func ChainMiddleware(middlewares ...Middleware) Middleware
ChainMiddleware chains multiple middleware functions
type NetHttpParser ¶
type NetHttpParser struct {
Request *http.Request
Response http.ResponseWriter
Locals map[string]any
Params map[string]string
}
func InitContext ¶
func InitContext(r *http.Request, w http.ResponseWriter) NetHttpParser
func (NetHttpParser) Abort ¶
func (c NetHttpParser) Abort() error
func (NetHttpParser) AddCustomAttributes ¶
func (c NetHttpParser) AddCustomAttributes(attr slog.Attr)
func (*NetHttpParser) AddParam ¶
func (c *NetHttpParser) AddParam(key, value string)
AddParam adds a single URL parameter
func (NetHttpParser) AddSpanAttribute ¶ added in v0.18.0
func (c NetHttpParser) AddSpanAttribute(key, value string)
func (NetHttpParser) AddSpanAttributes ¶ added in v0.18.0
func (c NetHttpParser) AddSpanAttributes(attrs map[string]string)
func (NetHttpParser) AddSpanEvent ¶ added in v0.18.0
func (c NetHttpParser) AddSpanEvent(name string, attrs map[string]string)
func (NetHttpParser) CheckUrlParam ¶
func (c NetHttpParser) CheckUrlParam(name string) (string, bool)
func (NetHttpParser) FileAttachment ¶
func (c NetHttpParser) FileAttachment(path, fileName string)
func (NetHttpParser) FormValue ¶
func (c NetHttpParser) FormValue(name string) string
func (NetHttpParser) GetBody ¶
func (c NetHttpParser) GetBody(target any) error
func (NetHttpParser) GetContext ¶ added in v0.22.0
func (c NetHttpParser) GetContext() context.Context
GetContext returns the context from the HTTP request
func (NetHttpParser) GetCookie ¶
func (c NetHttpParser) GetCookie(name string) (*http.Cookie, error)
GetCookie gets a cookie by name
func (NetHttpParser) GetCookies ¶
func (c NetHttpParser) GetCookies() []*http.Cookie
GetCookies gets all cookies
func (NetHttpParser) GetFormValue ¶
func (c NetHttpParser) GetFormValue(key string) string
GetFormValue gets form value
func (NetHttpParser) GetFormValues ¶
func (c NetHttpParser) GetFormValues(key string) []string
GetFormValues gets all form values for a key
func (NetHttpParser) GetHeader ¶
func (c NetHttpParser) GetHeader(target webFramework.HeaderInterface) error
func (NetHttpParser) GetHeaderValue ¶
func (c NetHttpParser) GetHeaderValue(name string) string
func (NetHttpParser) GetHttpHeader ¶
func (c NetHttpParser) GetHttpHeader() http.Header
func (NetHttpParser) GetLocal ¶
func (c NetHttpParser) GetLocal(name string) any
func (NetHttpParser) GetLocalString ¶
func (c NetHttpParser) GetLocalString(name string) string
func (NetHttpParser) GetMethod ¶
func (c NetHttpParser) GetMethod() string
func (NetHttpParser) GetPath ¶
func (c NetHttpParser) GetPath() string
func (NetHttpParser) GetPostFormValue ¶
func (c NetHttpParser) GetPostFormValue(key string) string
GetPostFormValue gets POST form value
func (NetHttpParser) GetPostFormValues ¶
func (c NetHttpParser) GetPostFormValues(key string) []string
GetPostFormValues gets all POST form values for a key
func (NetHttpParser) GetRawUrlQuery ¶
func (c NetHttpParser) GetRawUrlQuery() string
func (NetHttpParser) GetTraceContext ¶ added in v0.18.0
func (c NetHttpParser) GetTraceContext() trace.SpanContext
Tracing methods for NetHttpParser
func (NetHttpParser) GetUri ¶
func (c NetHttpParser) GetUri(target any) error
func (NetHttpParser) GetUrlParam ¶
func (c NetHttpParser) GetUrlParam(name string) string
func (NetHttpParser) GetUrlParams ¶
func (c NetHttpParser) GetUrlParams() map[string]string
func (NetHttpParser) GetUrlQuery ¶
func (c NetHttpParser) GetUrlQuery(target any) error
func (NetHttpParser) Next ¶
func (c NetHttpParser) Next() error
func (NetHttpParser) ParseCommand ¶
func (c NetHttpParser) ParseCommand(command, title string, request webFramework.RecordData, parser webFramework.FieldParser) string
func (NetHttpParser) ParseForm ¶
func (c NetHttpParser) ParseForm() error
ParseForm parses form data
func (NetHttpParser) ParseMultipartForm ¶
func (c NetHttpParser) ParseMultipartForm(maxMemory int64) error
ParseMultipartForm parses multipart form data
func (NetHttpParser) RecordSpanError ¶ added in v0.18.0
func (c NetHttpParser) RecordSpanError(err error, attrs map[string]string)
func (NetHttpParser) Redirect ¶
func (c NetHttpParser) Redirect(url string, statusCode int)
Redirect redirects to a URL
func (NetHttpParser) SaveFile ¶
func (c NetHttpParser) SaveFile(formTagName, path string) error
func (NetHttpParser) SendJSONRespBody ¶
func (c NetHttpParser) SendJSONRespBody(status int, resp any) error
func (NetHttpParser) ServeContent ¶
func (c NetHttpParser) ServeContent(name string, modtime time.Time, content io.ReadSeeker)
ServeContent serves content
func (NetHttpParser) ServeFile ¶
func (c NetHttpParser) ServeFile(name string)
ServeFile serves a file
func (NetHttpParser) SetContext ¶ added in v0.22.0
func (c NetHttpParser) SetContext(ctx context.Context)
SetContext updates the context in the HTTP request
func (NetHttpParser) SetCookie ¶
func (c NetHttpParser) SetCookie(cookie *http.Cookie)
SetCookie sets a cookie
func (NetHttpParser) SetLocal ¶
func (c NetHttpParser) SetLocal(name string, value any)
func (*NetHttpParser) SetParams ¶
func (c *NetHttpParser) SetParams(params map[string]string)
SetParams sets URL parameters (useful for routing)
func (NetHttpParser) SetReqHeader ¶
func (c NetHttpParser) SetReqHeader(name string, value string)
func (NetHttpParser) SetRespHeader ¶
func (c NetHttpParser) SetRespHeader(name string, value string)
func (NetHttpParser) SetTraceContext ¶ added in v0.18.0
func (c NetHttpParser) SetTraceContext(spanCtx trace.SpanContext)
func (NetHttpParser) StartSpan ¶ added in v0.18.0
func (c NetHttpParser) StartSpan(name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)