Documentation
¶
Index ¶
- func BadRequest(w http.ResponseWriter, r *http.Request, message *string, ...)
- func HealthCheckHandler(w http.ResponseWriter, r *http.Request)
- func InternalServerError(w http.ResponseWriter, r *http.Request)
- func NoContent(w http.ResponseWriter, r *http.Request)
- func NotFound(w http.ResponseWriter, r *http.Request, message string)
- func OK(w http.ResponseWriter, r *http.Request, data any)
- func Unauthorized(w http.ResponseWriter, r *http.Request, message string, ...)
- type HandleFunc
- type HealthCheckResponse
- type Options
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
BadRequest sends a 400 Bad Request response with the given message and errors.
func HealthCheckHandler ¶
func HealthCheckHandler(w http.ResponseWriter, r *http.Request)
HealthCheckHandler handles HTTP requests for checking the health status of the server.
func InternalServerError ¶
func InternalServerError(w http.ResponseWriter, r *http.Request)
InternalServerError sends a 500 Internal Server Error response.
func NoContent ¶
func NoContent(w http.ResponseWriter, r *http.Request)
NoContent sends a 204 No Content response.
func NotFound ¶
func NotFound(w http.ResponseWriter, r *http.Request, message string)
NotFound sends a 404 Not Found response with the given message.
func OK ¶
func OK(w http.ResponseWriter, r *http.Request, data any)
OK sends a 200 OK response with the given data.
func Unauthorized ¶
Unauthorized sends a 401 Unauthorized response with the given message and errors.
Types ¶
type HandleFunc ¶
type HandleFunc struct {
Pattern string
Handler http.HandlerFunc
}
HandleFunc is a struct that contains the pattern and the handler function.
type HealthCheckResponse ¶
type HealthCheckResponse struct {
Status string `json:"status"`
}
HealthCheckResponse represents the structure of the health check response
type Options ¶
type Options struct {
// Addr optionally specifies the TCP address for the server to listen on,
// in the form "host:port". If empty, ":http" (port 80) is used.
// The service names are defined in RFC 6335 and assigned by IANA.
// See net.Dial for details of the address format.
Addr string
// ReadTimeout is the maximum duration for reading the entire
// request, including the body. A zero or negative value means
// there will be no timeout.
//
// Because ReadTimeout does not let Handlers make per-request
// decisions on each request body's acceptable deadline or
// upload rate, most users will prefer to use
// ReadHeaderTimeout. It is valid to use them both.
ReadTimeout time.Duration
// WriteTimeout is the maximum duration before timing out
// writes of the response. It is reset whenever a new
// request's header is read. Like ReadTimeout, it does not
// let Handlers make decisions on a per-request basis.
// A zero or negative value means there will be no timeout.
WriteTimeout time.Duration
// IdleTimeout is the maximum amount of time to wait for the
// next request when keep-alives are enabled. If zero, the value
// of ReadTimeout is used. If negative, or if zero and ReadTimeout
// is zero or negative, there is no timeout.
IdleTimeout time.Duration
}
Options contains arguments to configure a Server instance.