Versions in this module Expand all Collapse all v1 v1.0.1 Jul 7, 2025 Changes in this version + var Response = ApiResponses + func DecodeJSON[T any](r *http.Request) (T, error) + func Send(w http.ResponseWriter, status int, data any) + type APIServer struct + Addr string + Router *http.ServeMux + Server http.Server + func NewApiServer(addr string, routes []RouteHandler) *APIServer + func (s *APIServer) ListenAndServe() error + type ApiResponses struct + BadRequest response + Created response + Forbidden response + Gzip func(w http.ResponseWriter, status int, data ...any) + NoContent response + NotFound response + Ok response + Send customResponse + ServerError response + StreamBytes func(w http.ResponseWriter, status int, bytes []byte, name string) + StreamFile func(w http.ResponseWriter, status int, binPath string, name string) + TooManyRequests response + Unauthorized response + type HTTPMethods struct + DELETE string + GET string + PATCH string + POST string + PUT string + type HandlerFn = func(http.ResponseWriter, *http.Request) + func RecoveryMW(next HandlerFn) HandlerFn + type Middleware = func(HandlerFn) HandlerFn + func CORSMW(origin string) Middleware + func HeaderAuthMW(validator func(token string) bool, header string, requireBearer bool) Middleware + func LoggerMW(logger *log.Logger) Middleware + func StaticBearerAuthMW(expectedKey string) Middleware + func TimeoutMW(d time.Duration) Middleware + type PathBuilder struct + func NewPathBuilder(base string) PathBuilder + func (pb *PathBuilder) Append(parts ...string) PathBuilder + func (pb *PathBuilder) Methods() HTTPMethods + type RouteHandler struct + Handler HandlerFn + MethodAndPath string + Middleware []Middleware