Documentation ¶
Index ¶
- Variables
- func FileServer(dir, prefix string) http.HandlerFunc
- func FileServerMiddleware(dir, prefix string) func(http.Handler) http.Handler
- func HealthCheckHandler() func(w http.ResponseWriter, r *http.Request)
- func MethodNotAllowedHandler() func(w http.ResponseWriter, r *http.Request)
- func NotFoundHandler() func(w http.ResponseWriter, r *http.Request)
- type Logger
- type Option
- type Server
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("not_found") ErrMethodNotAllowed = errors.New("method_not_allowed") )
Predefined errors
Functions ¶
func FileServerMiddleware ¶
File server middleware
func HealthCheckHandler ¶
func HealthCheckHandler() func(w http.ResponseWriter, r *http.Request)
HealthCheckHandler is a simple health check handler
func MethodNotAllowedHandler ¶
func MethodNotAllowedHandler() func(w http.ResponseWriter, r *http.Request)
MethodNotAllowedHandler is a handler for 405 Method Not Allowed
func NotFoundHandler ¶
func NotFoundHandler() func(w http.ResponseWriter, r *http.Request)
NotFoundHandler is a handler for 404 Not Found
Types ¶
type Logger ¶
type Logger interface {
Infof(format string, v ...interface{})
}
Logger is an interface for logging.
type Option ¶
type Option func(*Server)
Option is a function that configures the Server.
func WithLogger ¶
WithLogger sets the logger for the server. If no logger is set, no log messages will be printed.
func WithShutdownTimeout ¶
WithShutdownTimeout sets the timeout for graceful shutdown. If the timeout is exceeded, the server will be shutdown immediately. Default is 5 seconds.
Click to show internal directories.
Click to hide internal directories.