Documentation
¶
Index ¶
- func BadRequest(message string) error
- func ConvertToInt(value string) (int, error)
- func ConvertToPtrUrlURL(value string) (*url.URL, error)
- func ConvertToString(value string) (string, error)
- func ConvertToUuidUUID(value string) (uuid.UUID, error)
- func ExtractFromCookie(r *http.Request, name string) (string, bool)
- func ExtractFromFile(r *http.Request, name string) (*multipart.FileHeader, bool)
- func ExtractFromForm(r *http.Request, name string) (string, bool)
- func ExtractFromHeader(r *http.Request, name string) (string, bool)
- func ExtractFromPath(r *http.Request, name string) (string, bool)
- func Forbidden(message string) error
- func NotFound() error
- func RespondError(err error, w http.ResponseWriter, r *http.Request)
- func Unauthorized() error
- type HandlerValue
- type HttpError
- type JSONValue
- type ToResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
BadRequest returns an error that will respond with HTTP 400 Bad Request.
func ExtractFromFile ¶
func Forbidden ¶
Forbidden returns an error that will respond with HTTP 403 Forbidden.
func NotFound ¶
func NotFound() error
NotFound returns an error that will respond with HTTP 404 Not Found.
func RespondError ¶
func RespondError(err error, w http.ResponseWriter, r *http.Request)
RespondError writes an error response to the client. If the error is an HttpError, it uses the specified status code and message. Otherwise, it logs the error and returns a generic 500 Internal Server Error with a unique ID.
Types ¶
type HandlerValue ¶
func Handler ¶
func Handler(h http.Handler) HandlerValue
Handler wraps an http.Handler so it can be returned from hh route handlers. The wrapped handler will process the request further when Respond is called.
func (HandlerValue) Respond ¶
func (h HandlerValue) Respond(w http.ResponseWriter, r *http.Request)
type HttpError ¶
HttpError represents an HTTP error with a status code and message.
type JSONValue ¶
type JSONValue struct {
// contains filtered or unexported fields
}
type ToResponse ¶
type ToResponse interface {
Respond(w http.ResponseWriter, r *http.Request)
}
Source Files
¶
- converters.go
- errors.go
- extractors.go
- response.go