Documentation ¶
Overview ¶
Package http provides a set of utilities for handling HTTP requests and responses within the GoFr framework.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorEntityNotFound ¶ added in v1.7.0
ErrorEntityNotFound represents an error for when an entity is not found in the system.
func (ErrorEntityNotFound) Error ¶ added in v1.7.0
func (e ErrorEntityNotFound) Error() string
func (ErrorEntityNotFound) StatusCode ¶ added in v1.7.0
func (e ErrorEntityNotFound) StatusCode() int
type ErrorInvalidParam ¶ added in v1.7.0
type ErrorInvalidParam struct {
Params []string `json:"param,omitempty"` // Params contains the list of invalid parameter names.
}
ErrorInvalidParam represents an error for invalid parameter values.
func (ErrorInvalidParam) Error ¶ added in v1.7.0
func (e ErrorInvalidParam) Error() string
func (ErrorInvalidParam) StatusCode ¶ added in v1.7.0
func (e ErrorInvalidParam) StatusCode() int
type ErrorInvalidRoute ¶ added in v1.7.0
type ErrorInvalidRoute struct{}
ErrorInvalidRoute represents an error for invalid route in a request.
func (ErrorInvalidRoute) Error ¶ added in v1.7.0
func (e ErrorInvalidRoute) Error() string
func (ErrorInvalidRoute) StatusCode ¶ added in v1.7.0
func (e ErrorInvalidRoute) StatusCode() int
type ErrorMissingParam ¶ added in v1.7.0
type ErrorMissingParam struct {
Params []string `json:"param,omitempty"`
}
ErrorMissingParam represents an error for missing parameters in a request.
func (ErrorMissingParam) Error ¶ added in v1.7.0
func (e ErrorMissingParam) Error() string
func (ErrorMissingParam) StatusCode ¶ added in v1.7.0
func (e ErrorMissingParam) StatusCode() int
type Metrics ¶ added in v0.3.0
Metrics represents an interface for registering the default metrics in GoFr framework.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is an abstraction over the underlying http.Request. This abstraction is useful because it allows us to create applications without being aware of the transport. cmd.Request is another such abstraction.
func NewRequest ¶
NewRequest creates a new GoFr Request instance from the given http.Request.
type Responder ¶
type Responder struct {
// contains filtered or unexported fields
}
Responder encapsulates an http.ResponseWriter and is responsible for crafting structured responses.
func NewResponder ¶
func NewResponder(w http.ResponseWriter, method string) *Responder
NewResponder creates a new Responder instance from the given http.ResponseWriter..
func (Responder) HTTPStatusFromError ¶
HTTPStatusFromError maps errors to HTTP status codes.
type Router ¶
Router is responsible for routing HTTP request.
func (*Router) Add ¶
Add adds a new route with the given HTTP method, pattern, and handler, wrapping the handler with OpenTelemetry instrumentation.
func (*Router) UseMiddleware ¶ added in v1.5.0
func (rou *Router) UseMiddleware(mws ...Middleware)
UseMiddleware registers middlewares to the router.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package middleware provides a collection of middleware functions that handles various aspects of request handling, such as authentication, logging, tracing, and metrics collection.
|
Package middleware provides a collection of middleware functions that handles various aspects of request handling, such as authentication, logging, tracing, and metrics collection. |