Documentation
¶
Overview ¶
Package libFiber provides a Fiber web framework adapter for requestCore.
Index ¶
- Constants
- func AddSpanAttribute(c *fiber.Ctx, key, value string)
- func AddSpanAttributes(c *fiber.Ctx, attrs map[string]string)
- func AddSpanEvent(c *fiber.Ctx, name string, attrs map[string]string)
- func CustomTracingMiddleware(_ *libTracing.TracingManager) fiber.Handler
- func ErrorHandler(path, title string, handler ContextInitiator) fiber.ErrorHandler
- func ExtendMap(mp map[string]string) map[string][]string
- func Fiber(handler any) func(c *fiber.Ctx) error
- func GetSpanFromContext(c *fiber.Ctx) trace.Span
- func RecordSpanError(c *fiber.Ctx, err error, attrs map[string]string)
- func TracingMiddleware() fiber.Handler
- type ContextInitiator
- type FiberParser
- func (c FiberParser) Abort() error
- func (c FiberParser) AddCustomAttributes(attr slog.Attr)
- func (c FiberParser) AddSpanAttribute(key, value string)
- func (c FiberParser) AddSpanAttributes(attrs map[string]string)
- func (c FiberParser) AddSpanEvent(name string, attrs map[string]string)
- func (c FiberParser) CheckURLParam(name string) (string, bool)
- func (c FiberParser) FileAttachment(path, fileName string)
- func (c FiberParser) FormValue(name string) string
- func (c FiberParser) GetArgs(args ...any) map[string]string
- func (c FiberParser) GetBody(target any) error
- func (c FiberParser) GetContext() context.Context
- func (c FiberParser) GetHTTPHeader() http.Header
- func (c FiberParser) GetHeader(target webFramework.HeaderInterface) error
- func (c FiberParser) GetHeaderValue(name string) string
- func (c FiberParser) GetLocal(name string) any
- func (c FiberParser) GetLocalString(name string) string
- func (c FiberParser) GetMethod() string
- func (c FiberParser) GetPath() string
- func (c FiberParser) GetRawURLQuery() string
- func (c FiberParser) GetTraceContext() trace.SpanContext
- func (c FiberParser) GetURI(target any) error
- func (c FiberParser) GetURLParam(name string) string
- func (c FiberParser) GetURLParams() map[string]string
- func (c FiberParser) GetURLQuery(target any) error
- func (c FiberParser) Next() error
- func (c FiberParser) ParseCommand(command, title string, request webFramework.RecordData, ...) string
- func (c FiberParser) RecordSpanError(err error, attrs map[string]string)
- func (c FiberParser) SaveFile(formTagName, path string) error
- func (c FiberParser) SendJSONRespBody(status int, resp any) error
- func (c FiberParser) SetContext(ctx context.Context)
- func (c FiberParser) SetLocal(name string, value any)
- func (c FiberParser) SetReqHeader(name string, value string)
- func (c FiberParser) SetRespHeader(name string, value string)
- func (c FiberParser) SetTraceContext(_ trace.SpanContext)
- func (c FiberParser) StartSpan(_ string, _ ...trace.SpanStartOption) (context.Context, trace.Span)
Constants ¶
const FiberCtxKey = "fiber.Ctx"
FiberCtxKey is the user-value key used to store the Fiber context in fasthttp.
Variables ¶
This section is empty.
Functions ¶
func AddSpanAttribute ¶ added in v0.18.0
AddSpanAttribute adds an attribute to the current span in Fiber context
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(_ *libTracing.TracingManager) fiber.Handler
CustomTracingMiddleware creates a custom Fiber middleware with more control
func ErrorHandler ¶
func ErrorHandler(path, title string, handler ContextInitiator) fiber.ErrorHandler
ErrorHandler returns a Fiber error handler that maps errors to appropriate HTTP responses.
func ExtendMap ¶
ExtendMap converts a map[string]string to a map[string][]string for header compatibility.
func Fiber ¶
Fiber wraps a handler function into a Fiber handler that stores the context and invokes the handler.
func GetSpanFromContext ¶ added in v0.18.0
GetSpanFromContext gets the span from Fiber context
func RecordSpanError ¶ added in v0.18.0
RecordSpanError records an error in the current span
func TracingMiddleware ¶ added in v0.18.0
TracingMiddleware creates Fiber middleware for OpenTelemetry tracing using official otelfiber
Types ¶
type ContextInitiator ¶ added in v0.7.2
type ContextInitiator interface {
InitContext(c *fiber.Ctx) webFramework.WebFramework
Respond(int, int, string, any, bool, webFramework.WebFramework)
}
ContextInitiator defines the interface for initializing a web framework context and responding in Fiber.
type FiberParser ¶
FiberParser implements the webFramework.RequestParser interface for Fiber.
func InitContext ¶
func InitContext(c *fiber.Ctx) FiberParser
InitContext creates a FiberParser from the given Fiber context.
func (FiberParser) Abort ¶ added in v0.7.0
func (c FiberParser) Abort() error
Abort stops the middleware chain by sending the current response status.
func (FiberParser) AddCustomAttributes ¶ added in v0.13.2
func (c FiberParser) AddCustomAttributes(attr slog.Attr)
AddCustomAttributes adds a custom slog attribute to the Fiber context.
func (FiberParser) AddSpanAttribute ¶ added in v0.18.0
func (c FiberParser) AddSpanAttribute(key, value string)
AddSpanAttribute adds a single string attribute to the current tracing span.
func (FiberParser) AddSpanAttributes ¶ added in v0.18.0
func (c FiberParser) AddSpanAttributes(attrs map[string]string)
AddSpanAttributes adds multiple string attributes to the current tracing span.
func (FiberParser) AddSpanEvent ¶ added in v0.18.0
func (c FiberParser) AddSpanEvent(name string, attrs map[string]string)
AddSpanEvent adds an event with attributes to the current tracing span.
func (FiberParser) CheckURLParam ¶ added in v0.28.1
func (c FiberParser) CheckURLParam(name string) (string, bool)
CheckURLParam returns a URL path parameter by name and whether it exists.
func (FiberParser) FileAttachment ¶ added in v0.10.4
func (c FiberParser) FileAttachment(path, fileName string)
FileAttachment sends a file as an HTTP attachment with the given filename.
func (FiberParser) FormValue ¶ added in v0.10.1
func (c FiberParser) FormValue(name string) string
FormValue returns the form value for the given field name.
func (FiberParser) GetArgs ¶
func (c FiberParser) GetArgs(args ...any) map[string]string
GetArgs returns a map of common request arguments including user, app, action, and path.
func (FiberParser) GetBody ¶
func (c FiberParser) GetBody(target any) error
GetBody parses the request body into the target struct.
func (FiberParser) GetContext ¶ added in v0.22.0
func (c FiberParser) GetContext() context.Context
GetContext returns the context from the Fiber context
func (FiberParser) GetHTTPHeader ¶ added in v0.28.1
func (c FiberParser) GetHTTPHeader() http.Header
GetHTTPHeader returns the full HTTP header map from the Fiber request.
func (FiberParser) GetHeader ¶
func (c FiberParser) GetHeader(target webFramework.HeaderInterface) error
GetHeader parses request headers into the target struct.
func (FiberParser) GetHeaderValue ¶
func (c FiberParser) GetHeaderValue(name string) string
GetHeaderValue returns a single request header value by name.
func (FiberParser) GetLocal ¶
func (c FiberParser) GetLocal(name string) any
GetLocal returns a value stored in Fiber locals by name.
func (FiberParser) GetLocalString ¶
func (c FiberParser) GetLocalString(name string) string
GetLocalString returns a string value stored in Fiber locals by name.
func (FiberParser) GetMethod ¶
func (c FiberParser) GetMethod() string
GetMethod returns the HTTP method of the Fiber request.
func (FiberParser) GetPath ¶
func (c FiberParser) GetPath() string
GetPath returns the original URL path of the Fiber request.
func (FiberParser) GetRawURLQuery ¶ added in v0.28.1
func (c FiberParser) GetRawURLQuery() string
GetRawURLQuery returns the raw query string from the Fiber request.
func (FiberParser) GetTraceContext ¶ added in v0.18.0
func (c FiberParser) GetTraceContext() trace.SpanContext
GetTraceContext returns the trace span context from the Fiber user context.
func (FiberParser) GetURI ¶ added in v0.28.1
func (c FiberParser) GetURI(target any) error
GetURI parses URL path parameters into the target struct.
func (FiberParser) GetURLParam ¶ added in v0.28.1
func (c FiberParser) GetURLParam(name string) string
GetURLParam returns a single URL path parameter by name.
func (FiberParser) GetURLParams ¶ added in v0.28.1
func (c FiberParser) GetURLParams() map[string]string
GetURLParams returns all URL path parameters as a map.
func (FiberParser) GetURLQuery ¶ added in v0.28.1
func (c FiberParser) GetURLQuery(target any) error
GetURLQuery parses URL query parameters into the target struct.
func (FiberParser) Next ¶ added in v0.7.0
func (c FiberParser) Next() error
Next advances to the next middleware in the Fiber chain.
func (FiberParser) ParseCommand ¶
func (c FiberParser) ParseCommand(command, title string, request webFramework.RecordData, parser webFramework.FieldParser) string
ParseCommand parses a DML command template using local values and the provided request data.
func (FiberParser) RecordSpanError ¶ added in v0.18.0
func (c FiberParser) RecordSpanError(err error, attrs map[string]string)
RecordSpanError records an error with attributes on the current tracing span.
func (FiberParser) SaveFile ¶ added in v0.10.1
func (c FiberParser) SaveFile( formTagName, path string, ) error
SaveFile saves an uploaded file from the given form tag to the specified path.
func (FiberParser) SendJSONRespBody ¶ added in v0.7.0
func (c FiberParser) SendJSONRespBody(status int, resp any) error
SendJSONRespBody writes a JSON response with the given HTTP status code.
func (FiberParser) SetContext ¶ added in v0.22.0
func (c FiberParser) SetContext(ctx context.Context)
SetContext updates the context in the Fiber context
func (FiberParser) SetLocal ¶
func (c FiberParser) SetLocal(name string, value any)
SetLocal stores a value in Fiber locals by name.
func (FiberParser) SetReqHeader ¶ added in v0.7.5
func (c FiberParser) SetReqHeader(name string, value string)
SetReqHeader sets a request header value by name.
func (FiberParser) SetRespHeader ¶ added in v0.10.28
func (c FiberParser) SetRespHeader(name string, value string)
SetRespHeader sets a response header value by name.
func (FiberParser) SetTraceContext ¶ added in v0.18.0
func (c FiberParser) SetTraceContext(_ trace.SpanContext)
SetTraceContext sets the trace span context (no-op for Fiber).
func (FiberParser) StartSpan ¶ added in v0.18.0
func (c FiberParser) StartSpan(_ string, _ ...trace.SpanStartOption) (context.Context, trace.Span)
StartSpan starts a new tracing span from the Fiber user context.