handlers

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	HeaderContentType = "Content-Type"

	ContentTypeText        = "text/plain; charset=utf-8"
	ContentTypeJson        = "application/json"
	ContentTypeProblemJson = "application/problem+json"
)

Variables

View Source
var EMPTY_MAP = make(map[string]map[string]string)

Functions

func LivenessHandler added in v1.1.0

func LivenessHandler(w http.ResponseWriter, r *http.Request)

func MethodNotAllowedHandler

func MethodNotAllowedHandler(w http.ResponseWriter, _r *http.Request)

func NotFoundHandler

func NotFoundHandler(w http.ResponseWriter, _r *http.Request)

func SendBadGateway

func SendBadGateway(rw http.ResponseWriter, details ErrorDetails)

502 Bad Gateway

func SendBadRequest

func SendBadRequest(rw http.ResponseWriter, details ErrorDetails)

400 Bad Request

func SendConflict

func SendConflict(rw http.ResponseWriter, details ErrorDetails)

409 Conflict

func SendExpectationFailed

func SendExpectationFailed(rw http.ResponseWriter, details ErrorDetails)

417 Expectation Failed

func SendForbidden

func SendForbidden(rw http.ResponseWriter, details ErrorDetails)

403 Forbidden

func SendGatewayTimeout

func SendGatewayTimeout(rw http.ResponseWriter, details ErrorDetails)

504 Gateway Timeout

func SendGone

func SendGone(rw http.ResponseWriter, details ErrorDetails)

410 Gone

func SendHTTPVersionNotSupported

func SendHTTPVersionNotSupported(rw http.ResponseWriter, details ErrorDetails)

505 HTTP Version Not Supported

func SendInternalServerError

func SendInternalServerError(rw http.ResponseWriter, details ErrorDetails)

500 Internal Server Error

func SendJson

func SendJson(rw http.ResponseWriter, response []byte)

func SendLengthRequired

func SendLengthRequired(rw http.ResponseWriter, details ErrorDetails)

411 Length Required

func SendMethodNotAllowed

func SendMethodNotAllowed(rw http.ResponseWriter, details ErrorDetails)

405 Method Not Allowed

func SendNotAcceptable

func SendNotAcceptable(rw http.ResponseWriter, details ErrorDetails)

406 Not Acceptable

func SendNotFound

func SendNotFound(rw http.ResponseWriter, details ErrorDetails)

404 Not Found

func SendNotImplemented

func SendNotImplemented(rw http.ResponseWriter, details ErrorDetails)

501 Not Implemented

func SendPayloadTooLarge

func SendPayloadTooLarge(rw http.ResponseWriter, details ErrorDetails)

413 Payload Too Large

func SendPreconditionFailed

func SendPreconditionFailed(rw http.ResponseWriter, details ErrorDetails)

412 Precondition Failed

func SendRangeNotSatisfiable

func SendRangeNotSatisfiable(rw http.ResponseWriter, details ErrorDetails)

416 Range Not Satisfiable

func SendRequestTimeout

func SendRequestTimeout(rw http.ResponseWriter, details ErrorDetails)

408 Request Timeout

func SendServiceUnavailable

func SendServiceUnavailable(rw http.ResponseWriter, details ErrorDetails)

503 Service Unavailable

func SendStructAsJson added in v1.4.0

func SendStructAsJson(rw http.ResponseWriter, v interface{})

func SendText

func SendText(rw http.ResponseWriter, response string)

func SendTooManyRequests

func SendTooManyRequests(rw http.ResponseWriter, details ErrorDetails)

429 Too Many Requests

func SendURITooLong

func SendURITooLong(rw http.ResponseWriter, details ErrorDetails)

414 URI Too Long

func SendUnauthorized

func SendUnauthorized(rw http.ResponseWriter, details ErrorDetails)

401 Unauthorized

func SendUnprocessableEntity

func SendUnprocessableEntity(rw http.ResponseWriter, details ErrorDetails)

422 Unprocessable Entity

func SendUnsupportedMediaType

func SendUnsupportedMediaType(rw http.ResponseWriter, details ErrorDetails)

415 Unsupported Media Type

func SendValidationError added in v1.3.0

func SendValidationError(rw http.ResponseWriter, details ErrorDetails)

func ValidatingHandler added in v1.2.0

func ValidatingHandler[T any](handler func(http.ResponseWriter, *http.Request, *T)) func(w http.ResponseWriter, r *http.Request)

Types

type ErrorDetails added in v1.3.0

type ErrorDetails map[string]map[string]string

type HttpError

type HttpError struct {
	Title   string `json:"title"`
	Status  int    `json:"status"`
	Details any    `json:"details,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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