router

package
v0.0.109 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BunRouterAdapter

type BunRouterAdapter struct {
	// contains filtered or unexported fields
}

BunRouterAdapter adapts uptrace/bunrouter to work with our Router interface

func NewBunRouterAdapter

func NewBunRouterAdapter(router *bunrouter.Router) *BunRouterAdapter

NewBunRouterAdapter creates a new bunrouter adapter

func NewBunRouterAdapterDefault

func NewBunRouterAdapterDefault() *BunRouterAdapter

NewBunRouterAdapterDefault creates a new bunrouter adapter with default router

func (*BunRouterAdapter) GetBunRouter

func (b *BunRouterAdapter) GetBunRouter() *bunrouter.Router

GetBunRouter returns the underlying bunrouter for direct access

func (*BunRouterAdapter) HandleFunc

func (b *BunRouterAdapter) HandleFunc(pattern string, handler common.HTTPHandlerFunc) common.RouteRegistration

func (*BunRouterAdapter) ServeHTTP

type BunRouterConfig

type BunRouterConfig struct {
	UseStrictSlash         bool
	RedirectTrailingSlash  bool
	HandleMethodNotAllowed bool
	HandleOPTIONS          bool
	GlobalOPTIONS          http.Handler
	GlobalMethodNotAllowed http.Handler
	PanicHandler           func(http.ResponseWriter, *http.Request, interface{})
}

BunRouterConfig holds bunrouter-specific configuration

func DefaultBunRouterConfig

func DefaultBunRouterConfig() *BunRouterConfig

DefaultBunRouterConfig returns default bunrouter configuration

type BunRouterRegistration

type BunRouterRegistration struct {
	// contains filtered or unexported fields
}

BunRouterRegistration implements RouteRegistration for bunrouter

func (*BunRouterRegistration) Methods

func (b *BunRouterRegistration) Methods(methods ...string) common.RouteRegistration

func (*BunRouterRegistration) PathPrefix

func (b *BunRouterRegistration) PathPrefix(prefix string) common.RouteRegistration

type BunRouterRequest

type BunRouterRequest struct {
	// contains filtered or unexported fields
}

BunRouterRequest adapts bunrouter.Request to our Request interface

func NewBunRouterRequest

func NewBunRouterRequest(req bunrouter.Request) *BunRouterRequest

NewBunRouterRequest creates a new BunRouterRequest adapter

func (*BunRouterRequest) AllHeaders

func (b *BunRouterRequest) AllHeaders() map[string]string

func (*BunRouterRequest) AllQueryParams added in v0.0.53

func (b *BunRouterRequest) AllQueryParams() map[string]string

func (*BunRouterRequest) Body

func (b *BunRouterRequest) Body() ([]byte, error)

func (*BunRouterRequest) Header

func (b *BunRouterRequest) Header(key string) string

func (*BunRouterRequest) Method

func (b *BunRouterRequest) Method() string

func (*BunRouterRequest) PathParam

func (b *BunRouterRequest) PathParam(key string) string

func (*BunRouterRequest) QueryParam

func (b *BunRouterRequest) QueryParam(key string) string

func (*BunRouterRequest) URL

func (b *BunRouterRequest) URL() string

func (*BunRouterRequest) UnderlyingRequest added in v0.0.72

func (b *BunRouterRequest) UnderlyingRequest() *http.Request

UnderlyingRequest returns the underlying *http.Request This is useful when you need to pass the request to other handlers

type HTTPRequest

type HTTPRequest struct {
	// contains filtered or unexported fields
}

HTTPRequest adapts standard http.Request to our Request interface

func NewHTTPRequest

func NewHTTPRequest(r *http.Request) *HTTPRequest

func (*HTTPRequest) AllHeaders

func (h *HTTPRequest) AllHeaders() map[string]string

func (*HTTPRequest) AllQueryParams added in v0.0.53

func (h *HTTPRequest) AllQueryParams() map[string]string

func (*HTTPRequest) Body

func (h *HTTPRequest) Body() ([]byte, error)

func (*HTTPRequest) Header

func (h *HTTPRequest) Header(key string) string

func (*HTTPRequest) Method

func (h *HTTPRequest) Method() string

func (*HTTPRequest) PathParam

func (h *HTTPRequest) PathParam(key string) string

func (*HTTPRequest) QueryParam

func (h *HTTPRequest) QueryParam(key string) string

func (*HTTPRequest) URL

func (h *HTTPRequest) URL() string

func (*HTTPRequest) UnderlyingRequest added in v0.0.70

func (h *HTTPRequest) UnderlyingRequest() *http.Request

UnderlyingRequest returns the underlying *http.Request This is useful when you need to pass the request to other handlers

type HTTPResponseWriter

type HTTPResponseWriter struct {
	// contains filtered or unexported fields
}

HTTPResponseWriter adapts our ResponseWriter interface to standard http.ResponseWriter

func NewHTTPResponseWriter

func NewHTTPResponseWriter(w http.ResponseWriter) *HTTPResponseWriter

func (*HTTPResponseWriter) SetHeader

func (h *HTTPResponseWriter) SetHeader(key, value string)

func (*HTTPResponseWriter) UnderlyingResponseWriter added in v0.0.70

func (h *HTTPResponseWriter) UnderlyingResponseWriter() http.ResponseWriter

UnderlyingResponseWriter returns the underlying http.ResponseWriter This is useful when you need to pass the response writer to other handlers

func (*HTTPResponseWriter) Write

func (h *HTTPResponseWriter) Write(data []byte) (int, error)

func (*HTTPResponseWriter) WriteHeader

func (h *HTTPResponseWriter) WriteHeader(statusCode int)

func (*HTTPResponseWriter) WriteJSON

func (h *HTTPResponseWriter) WriteJSON(data interface{}) error

type MuxAdapter

type MuxAdapter struct {
	// contains filtered or unexported fields
}

MuxAdapter adapts Gorilla Mux to work with our Router interface

func NewMuxAdapter

func NewMuxAdapter(router *mux.Router) *MuxAdapter

NewMuxAdapter creates a new Mux adapter

func (*MuxAdapter) HandleFunc

func (m *MuxAdapter) HandleFunc(pattern string, handler common.HTTPHandlerFunc) common.RouteRegistration

func (*MuxAdapter) ServeHTTP

func (m *MuxAdapter) ServeHTTP(w common.ResponseWriter, r common.Request)

type MuxParamExtractor

type MuxParamExtractor struct{}

MuxParamExtractor extracts parameters from Gorilla Mux

func (MuxParamExtractor) ExtractParams

func (m MuxParamExtractor) ExtractParams(r *http.Request) map[string]string

type MuxRouteRegistration

type MuxRouteRegistration struct {
	// contains filtered or unexported fields
}

MuxRouteRegistration implements RouteRegistration for Mux

func (*MuxRouteRegistration) Methods

func (m *MuxRouteRegistration) Methods(methods ...string) common.RouteRegistration

func (*MuxRouteRegistration) PathPrefix

func (m *MuxRouteRegistration) PathPrefix(prefix string) common.RouteRegistration

type PathParamExtractor

type PathParamExtractor interface {
	ExtractParams(*http.Request) map[string]string
}

PathParamExtractor extracts path parameters from different router types

type RouterConfig

type RouterConfig struct {
	PathPrefix     string
	Middleware     []func(http.Handler) http.Handler
	ParamExtractor PathParamExtractor
}

RouterConfig holds router configuration

func DefaultRouterConfig

func DefaultRouterConfig() *RouterConfig

DefaultRouterConfig returns default router configuration

type StandardBunRouterAdapter

type StandardBunRouterAdapter struct {
	*BunRouterAdapter
}

StandardBunRouterAdapter creates routes compatible with standard bunrouter handlers

func NewStandardBunRouterAdapter

func NewStandardBunRouterAdapter() *StandardBunRouterAdapter

func (*StandardBunRouterAdapter) RegisterRoute

func (s *StandardBunRouterAdapter) RegisterRoute(method, pattern string, handler func(http.ResponseWriter, *http.Request, map[string]string))

RegisterRoute registers a route that works with the existing Handler

func (*StandardBunRouterAdapter) RegisterRouteWithParams

func (s *StandardBunRouterAdapter) RegisterRouteWithParams(method, pattern string, paramNames []string, handler func(http.ResponseWriter, *http.Request, map[string]string))

RegisterRouteWithParams registers a route with explicit parameter extraction

type StandardMuxAdapter

type StandardMuxAdapter struct {
	*MuxAdapter
}

StandardMuxAdapter creates routes compatible with standard http.HandlerFunc

func NewStandardMuxAdapter

func NewStandardMuxAdapter() *StandardMuxAdapter

func (*StandardMuxAdapter) GetMuxRouter

func (s *StandardMuxAdapter) GetMuxRouter() *mux.Router

GetMuxRouter returns the underlying mux router for direct access

func (*StandardMuxAdapter) RegisterRoute

func (s *StandardMuxAdapter) RegisterRoute(pattern string, handler func(http.ResponseWriter, *http.Request, map[string]string)) *mux.Route

RegisterRoute registers a route that works with the existing Handler

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL