Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Mount ¶ added in v0.187.0
func Mount(mux Multiplexer, pattern string, handler http.Handler)
Mount will help to register a handler on a request multiplexer in both as the concrete path to the handler and as a prefix match. example:
if pattern -> "/something" registered as "/something" for exact match registered as "/something/" for prefix match
Example ¶
package main
import (
"net/http"
"go.llib.dev/frameless/pkg/httpkit"
)
func main() {
var (
apiV0 http.Handler
webUI http.Handler
mux = http.NewServeMux()
)
httpkit.Mount(mux, "/api/v0", apiV0)
httpkit.Mount(mux, "/ui", webUI)
}
func WithMiddleware ¶ added in v0.211.0
func WithMiddleware(handler http.Handler, ffns ...MiddlewareFactoryFunc) http.Handler
WithMiddleware will combine an http.Handler with a stack of middleware functions. The order in which you pass the MiddlewareFactoryFunc -s is the same as the order, they will be called during the http.Handler.ServeHTTP method call.
Types ¶
type AccessLog ¶
type AccessLog struct {
Next http.Handler
AdditionalLoggingDetail func(w http.ResponseWriter, r *http.Request) logger.LoggingDetail
}
type MiddlewareFactoryFunc ¶ added in v0.211.0
MiddlewareFactoryFunc is a constructor function that is meant to wrap an http.Handler with given middleware. Its http.Handler argument represents the next middleware http.Handler in the pipeline.
type Multiplexer ¶ added in v0.211.0
Multiplexer represents a http request Multiplexer.
type RetryRoundTripper ¶
type RetryRoundTripper struct {
// Transport specifies the mechanism by which individual
// HTTP requests are made.
//
// Default: http.DefaultTransport
Transport http.RoundTripper
// RetryStrategy will be used to evaluate if a new retry attempt should be done.
//
// Default: retry.ExponentialBackoff
RetryStrategy retry.Strategy[retry.FailureCount]
}
Click to show internal directories.
Click to hide internal directories.