Documentation
¶
Overview ¶
Package middleware provides infrastructure layer middleware adapters for integrating framework-agnostic middleware with specific HTTP frameworks.
Package middleware provides infrastructure layer middleware adapters for integrating framework-agnostic middleware with specific HTTP frameworks.
Package middleware provides infrastructure layer middleware adapters for integrating framework-agnostic middleware with specific HTTP frameworks.
Index ¶
- func NewEchoRequest(c echo.Context) core.Request
- type EchoAdapter
- type EchoChainAdapter
- type EchoMiddlewareWrapper
- type EchoOrchestratorAdapter
- type EchoRegistryAdapter
- type EchoRequest
- func (r *EchoRequest) Accepts(contentType string) bool
- func (r *EchoRequest) AcceptsEncoding(encoding string) bool
- func (r *EchoRequest) AcceptsLanguage(language string) bool
- func (r *EchoRequest) Body() io.Reader
- func (r *EchoRequest) ContentLength() int64
- func (r *EchoRequest) ContentType() string
- func (r *EchoRequest) Context() context.Context
- func (r *EchoRequest) Cookie(name string) (*http.Cookie, error)
- func (r *EchoRequest) Cookies() []*http.Cookie
- func (r *EchoRequest) Form() (url.Values, error)
- func (r *EchoRequest) FormValue(name string) string
- func (r *EchoRequest) ForwardedFor() string
- func (r *EchoRequest) Get(key string) any
- func (r *EchoRequest) Headers() http.Header
- func (r *EchoRequest) Host() string
- func (r *EchoRequest) IsAJAX() bool
- func (r *EchoRequest) IsJSON() bool
- func (r *EchoRequest) IsSecure() bool
- func (r *EchoRequest) IsWebSocket() bool
- func (r *EchoRequest) IsXML() bool
- func (r *EchoRequest) Method() string
- func (r *EchoRequest) MultipartForm() (*multipart.Form, error)
- func (r *EchoRequest) Param(name string) string
- func (r *EchoRequest) Params() map[string]string
- func (r *EchoRequest) Path() string
- func (r *EchoRequest) Query() map[string][]string
- func (r *EchoRequest) RealIP() string
- func (r *EchoRequest) Referer() string
- func (r *EchoRequest) RemoteAddr() string
- func (r *EchoRequest) RequestID() string
- func (r *EchoRequest) Set(key string, value any)
- func (r *EchoRequest) Timestamp() time.Time
- func (r *EchoRequest) URL() *http.Request
- func (r *EchoRequest) UserAgent() string
- func (r *EchoRequest) WithContext(ctx context.Context) core.Request
- type EchoResponseBuilder
- func (b *EchoResponseBuilder) Body(body io.Reader) *EchoResponseBuilder
- func (b *EchoResponseBuilder) BodyBytes(data []byte) *EchoResponseBuilder
- func (b *EchoResponseBuilder) BodyString(data string) *EchoResponseBuilder
- func (b *EchoResponseBuilder) Build() core.Response
- func (b *EchoResponseBuilder) ContentType(contentType string) *EchoResponseBuilder
- func (b *EchoResponseBuilder) Cookie(cookie *http.Cookie) *EchoResponseBuilder
- func (b *EchoResponseBuilder) Error(statusCode int, err error) *EchoResponseBuilder
- func (b *EchoResponseBuilder) HTML(html string) *EchoResponseBuilder
- func (b *EchoResponseBuilder) Header(key, value string) *EchoResponseBuilder
- func (b *EchoResponseBuilder) Headers(headers map[string]string) *EchoResponseBuilder
- func (b *EchoResponseBuilder) JSON(data any) *EchoResponseBuilder
- func (b *EchoResponseBuilder) Redirect(statusCode int, url string) *EchoResponseBuilder
- func (b *EchoResponseBuilder) RequestID(requestID string) *EchoResponseBuilder
- func (b *EchoResponseBuilder) Send() error
- func (b *EchoResponseBuilder) Status(code int) *EchoResponseBuilder
- func (b *EchoResponseBuilder) Text(text string) *EchoResponseBuilder
- type EchoResponseConverter
- type EchoResponseWrapper
- type EchoResponseWriter
- func (w *EchoResponseWriter) Bytes() []byte
- func (w *EchoResponseWriter) Flush() error
- func (w *EchoResponseWriter) String() string
- func (w *EchoResponseWriter) Write(p []byte) (n int, err error)
- func (w *EchoResponseWriter) WriteHTML(html string) error
- func (w *EchoResponseWriter) WriteJSON(data any) error
- func (w *EchoResponseWriter) WriteString(s string) (int, error)
- func (w *EchoResponseWriter) WriteText(text string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EchoAdapter ¶
type EchoAdapter struct {
// contains filtered or unexported fields
}
EchoAdapter adapts our framework-agnostic middleware to Echo's middleware interface. This adapter follows the adapter pattern to bridge between our clean architecture and Echo's framework-specific implementation.
func NewEchoAdapter ¶
func NewEchoAdapter(middleware core.Middleware) *EchoAdapter
NewEchoAdapter creates a new Echo adapter for the given middleware.
func (*EchoAdapter) ToEchoMiddleware ¶
func (a *EchoAdapter) ToEchoMiddleware() echo.MiddlewareFunc
ToEchoMiddleware converts our middleware to Echo's middleware function. This method handles the conversion between our Request/Response interfaces and Echo's echo.Context, ensuring proper error handling and context management.
type EchoChainAdapter ¶
type EchoChainAdapter struct {
// contains filtered or unexported fields
}
EchoChainAdapter adapts our middleware chain to Echo's middleware chain.
func NewEchoChainAdapter ¶
func NewEchoChainAdapter(chain core.Chain) *EchoChainAdapter
NewEchoChainAdapter creates a new Echo chain adapter.
func (*EchoChainAdapter) ToEchoMiddleware ¶
func (a *EchoChainAdapter) ToEchoMiddleware() echo.MiddlewareFunc
ToEchoMiddleware converts our middleware chain to Echo's middleware function.
type EchoMiddlewareWrapper ¶
type EchoMiddlewareWrapper struct {
// contains filtered or unexported fields
}
EchoMiddlewareWrapper wraps Echo middleware to implement our Middleware interface.
func (*EchoMiddlewareWrapper) Name ¶
func (w *EchoMiddlewareWrapper) Name() string
Name returns the name of this middleware wrapper.
func (*EchoMiddlewareWrapper) Priority ¶
func (w *EchoMiddlewareWrapper) Priority() int
Priority returns the priority of this middleware wrapper.
type EchoOrchestratorAdapter ¶
type EchoOrchestratorAdapter struct {
// contains filtered or unexported fields
}
EchoOrchestratorAdapter adapts our orchestrator to Echo's middleware system.
func NewEchoOrchestratorAdapter ¶
func NewEchoOrchestratorAdapter(orchestrator core.Orchestrator) *EchoOrchestratorAdapter
NewEchoOrchestratorAdapter creates a new Echo orchestrator adapter.
func (*EchoOrchestratorAdapter) GetEchoChain ¶
func (a *EchoOrchestratorAdapter) GetEchoChain(name string) (echo.MiddlewareFunc, bool)
GetEchoChain retrieves a named chain and converts it to Echo middleware.
func (*EchoOrchestratorAdapter) RegisterEchoChain ¶
func (a *EchoOrchestratorAdapter) RegisterEchoChain(name string, chainType core.ChainType) error
RegisterEchoChain registers a named chain for use with Echo.
func (*EchoOrchestratorAdapter) SetupEchoMiddleware ¶
SetupEchoMiddleware sets up Echo middleware based on our orchestrator configuration.
type EchoRegistryAdapter ¶
type EchoRegistryAdapter struct {
// contains filtered or unexported fields
}
EchoRegistryAdapter adapts our middleware registry to Echo's middleware system.
func NewEchoRegistryAdapter ¶
func NewEchoRegistryAdapter(registry core.Registry) *EchoRegistryAdapter
NewEchoRegistryAdapter creates a new Echo registry adapter.
func (*EchoRegistryAdapter) GetEchoMiddleware ¶
func (a *EchoRegistryAdapter) GetEchoMiddleware(name string) (echo.MiddlewareFunc, bool)
GetEchoMiddleware retrieves middleware by name and converts it to Echo middleware.
func (*EchoRegistryAdapter) RegisterEchoMiddleware ¶
func (a *EchoRegistryAdapter) RegisterEchoMiddleware(name string, echoMiddleware echo.MiddlewareFunc) error
RegisterEchoMiddleware registers Echo middleware with our registry.
type EchoRequest ¶
type EchoRequest struct {
// contains filtered or unexported fields
}
EchoRequest wraps Echo's echo.Context to implement our Request interface. This adapter provides access to Echo's request data through our framework-agnostic interface.
func (*EchoRequest) Accepts ¶
func (r *EchoRequest) Accepts(contentType string) bool
Accepts returns true if the request accepts the given content type
func (*EchoRequest) AcceptsEncoding ¶
func (r *EchoRequest) AcceptsEncoding(encoding string) bool
AcceptsEncoding returns true if the request accepts the given encoding
func (*EchoRequest) AcceptsLanguage ¶
func (r *EchoRequest) AcceptsLanguage(language string) bool
AcceptsLanguage returns true if the request accepts the given language
func (*EchoRequest) Body ¶
func (r *EchoRequest) Body() io.Reader
Body returns the request body as an io.Reader
func (*EchoRequest) ContentLength ¶
func (r *EchoRequest) ContentLength() int64
ContentLength returns the length of the request body
func (*EchoRequest) ContentType ¶
func (r *EchoRequest) ContentType() string
ContentType returns the Content-Type header value
func (*EchoRequest) Context ¶
func (r *EchoRequest) Context() context.Context
Context returns the request context
func (*EchoRequest) Cookie ¶
func (r *EchoRequest) Cookie(name string) (*http.Cookie, error)
Cookie returns a cookie by name
func (*EchoRequest) Cookies ¶
func (r *EchoRequest) Cookies() []*http.Cookie
Cookies returns all cookies
func (*EchoRequest) Form ¶
func (r *EchoRequest) Form() (url.Values, error)
Form returns the parsed form data
func (*EchoRequest) FormValue ¶
func (r *EchoRequest) FormValue(name string) string
FormValue returns a form value by name
func (*EchoRequest) ForwardedFor ¶
func (r *EchoRequest) ForwardedFor() string
ForwardedFor returns the X-Forwarded-For header value
func (*EchoRequest) Get ¶
func (r *EchoRequest) Get(key string) any
Get retrieves a value from the request context
func (*EchoRequest) Headers ¶
func (r *EchoRequest) Headers() http.Header
Headers returns the request headers
func (*EchoRequest) IsAJAX ¶
func (r *EchoRequest) IsAJAX() bool
IsAJAX returns true if the request is an AJAX request
func (*EchoRequest) IsJSON ¶
func (r *EchoRequest) IsJSON() bool
IsJSON returns true if the request expects JSON response
func (*EchoRequest) IsSecure ¶
func (r *EchoRequest) IsSecure() bool
IsSecure returns true if the request was made over HTTPS
func (*EchoRequest) IsWebSocket ¶
func (r *EchoRequest) IsWebSocket() bool
IsWebSocket returns true if the request is a WebSocket upgrade request
func (*EchoRequest) IsXML ¶
func (r *EchoRequest) IsXML() bool
IsXML returns true if the request expects XML response
func (*EchoRequest) MultipartForm ¶
func (r *EchoRequest) MultipartForm() (*multipart.Form, error)
MultipartForm returns the parsed multipart form data
func (*EchoRequest) Param ¶
func (r *EchoRequest) Param(name string) string
Param returns a path parameter by name
func (*EchoRequest) Params ¶
func (r *EchoRequest) Params() map[string]string
Params returns all path parameters
func (*EchoRequest) Query ¶
func (r *EchoRequest) Query() map[string][]string
Query returns the query parameters
func (*EchoRequest) RealIP ¶
func (r *EchoRequest) RealIP() string
RealIP returns the real IP address of the client
func (*EchoRequest) Referer ¶
func (r *EchoRequest) Referer() string
Referer returns the Referer header value
func (*EchoRequest) RemoteAddr ¶
func (r *EchoRequest) RemoteAddr() string
RemoteAddr returns the client's network address
func (*EchoRequest) RequestID ¶
func (r *EchoRequest) RequestID() string
RequestID returns the request ID if present
func (*EchoRequest) Set ¶
func (r *EchoRequest) Set(key string, value any)
Set stores a value in the request context
func (*EchoRequest) Timestamp ¶
func (r *EchoRequest) Timestamp() time.Time
Timestamp returns when the request was received
func (*EchoRequest) UserAgent ¶
func (r *EchoRequest) UserAgent() string
UserAgent returns the User-Agent header value
func (*EchoRequest) WithContext ¶
func (r *EchoRequest) WithContext(ctx context.Context) core.Request
WithContext returns a new request with the given context
type EchoResponseBuilder ¶
type EchoResponseBuilder struct {
// contains filtered or unexported fields
}
EchoResponseBuilder provides a builder pattern for creating responses that can be easily applied to Echo contexts.
func NewEchoResponseBuilder ¶
func NewEchoResponseBuilder(c echo.Context) *EchoResponseBuilder
NewEchoResponseBuilder creates a new Echo response builder.
func (*EchoResponseBuilder) Body ¶
func (b *EchoResponseBuilder) Body(body io.Reader) *EchoResponseBuilder
Body sets the response body.
func (*EchoResponseBuilder) BodyBytes ¶
func (b *EchoResponseBuilder) BodyBytes(data []byte) *EchoResponseBuilder
BodyBytes sets the response body as bytes.
func (*EchoResponseBuilder) BodyString ¶
func (b *EchoResponseBuilder) BodyString(data string) *EchoResponseBuilder
BodyString sets the response body as a string.
func (*EchoResponseBuilder) Build ¶
func (b *EchoResponseBuilder) Build() core.Response
Build returns the built response.
func (*EchoResponseBuilder) ContentType ¶
func (b *EchoResponseBuilder) ContentType(contentType string) *EchoResponseBuilder
ContentType sets the Content-Type header.
func (*EchoResponseBuilder) Cookie ¶
func (b *EchoResponseBuilder) Cookie(cookie *http.Cookie) *EchoResponseBuilder
Cookie adds a cookie to the response.
func (*EchoResponseBuilder) Error ¶
func (b *EchoResponseBuilder) Error(statusCode int, err error) *EchoResponseBuilder
Error sets the response to return an error.
func (*EchoResponseBuilder) HTML ¶
func (b *EchoResponseBuilder) HTML(html string) *EchoResponseBuilder
HTML sets the response to return HTML.
func (*EchoResponseBuilder) Header ¶
func (b *EchoResponseBuilder) Header(key, value string) *EchoResponseBuilder
Header adds a header to the response.
func (*EchoResponseBuilder) Headers ¶
func (b *EchoResponseBuilder) Headers(headers map[string]string) *EchoResponseBuilder
Headers adds multiple headers to the response.
func (*EchoResponseBuilder) JSON ¶
func (b *EchoResponseBuilder) JSON(data any) *EchoResponseBuilder
JSON sets the response to return JSON data.
func (*EchoResponseBuilder) Redirect ¶
func (b *EchoResponseBuilder) Redirect(statusCode int, url string) *EchoResponseBuilder
Redirect sets the response to redirect to the given URL.
func (*EchoResponseBuilder) RequestID ¶
func (b *EchoResponseBuilder) RequestID(requestID string) *EchoResponseBuilder
RequestID sets the request ID for the response.
func (*EchoResponseBuilder) Send ¶
func (b *EchoResponseBuilder) Send() error
Send applies the response to Echo and returns any error.
func (*EchoResponseBuilder) Status ¶
func (b *EchoResponseBuilder) Status(code int) *EchoResponseBuilder
Status sets the response status code.
func (*EchoResponseBuilder) Text ¶
func (b *EchoResponseBuilder) Text(text string) *EchoResponseBuilder
Text sets the response to return plain text.
type EchoResponseConverter ¶
type EchoResponseConverter struct{}
EchoResponseConverter provides utility functions for converting between Echo responses and our framework-agnostic responses.
func NewEchoResponseConverter ¶
func NewEchoResponseConverter() *EchoResponseConverter
NewEchoResponseConverter creates a new Echo response converter.
func (*EchoResponseConverter) FromEchoResponse ¶
func (c *EchoResponseConverter) FromEchoResponse(echoResp *echo.Response) core.Response
FromEchoResponse converts an Echo response to our Response interface. Note: This is a simplified conversion as Echo doesn't provide direct access to all response data in this context.
type EchoResponseWrapper ¶
type EchoResponseWrapper struct {
// contains filtered or unexported fields
}
EchoResponseWrapper wraps our Response interface to work with Echo's response system. This adapter provides a bridge between our framework-agnostic response and Echo's response handling mechanisms.
func NewEchoResponseWrapper ¶
func NewEchoResponseWrapper(resp core.Response, c echo.Context) *EchoResponseWrapper
NewEchoResponseWrapper creates a new Echo response wrapper.
func (*EchoResponseWrapper) ApplyToEcho ¶
func (w *EchoResponseWrapper) ApplyToEcho() error
ApplyToEcho applies our response to Echo's context. This method handles status codes, headers, cookies, and body writing.
type EchoResponseWriter ¶
type EchoResponseWriter struct {
// contains filtered or unexported fields
}
EchoResponseWriter provides a writer that can be used to write responses directly to Echo contexts while maintaining our framework-agnostic interface.
func NewEchoResponseWriter ¶
func NewEchoResponseWriter(c echo.Context) *EchoResponseWriter
NewEchoResponseWriter creates a new Echo response writer.
func (*EchoResponseWriter) Bytes ¶
func (w *EchoResponseWriter) Bytes() []byte
Bytes returns the buffered content as bytes.
func (*EchoResponseWriter) Flush ¶
func (w *EchoResponseWriter) Flush() error
Flush writes the buffered content to Echo's response writer.
func (*EchoResponseWriter) String ¶
func (w *EchoResponseWriter) String() string
String returns the buffered content as a string.
func (*EchoResponseWriter) Write ¶
func (w *EchoResponseWriter) Write(p []byte) (n int, err error)
Write implements io.Writer interface.
func (*EchoResponseWriter) WriteHTML ¶
func (w *EchoResponseWriter) WriteHTML(html string) error
WriteHTML writes HTML to the response.
func (*EchoResponseWriter) WriteJSON ¶
func (w *EchoResponseWriter) WriteJSON(data any) error
WriteJSON writes JSON data to the response.
func (*EchoResponseWriter) WriteString ¶
func (w *EchoResponseWriter) WriteString(s string) (int, error)
WriteString writes a string to the response.
func (*EchoResponseWriter) WriteText ¶
func (w *EchoResponseWriter) WriteText(text string) error
WriteText writes plain text to the response.