- Use github.com/google/go-cmp to test response body.
- Switch to standard
slog
package for logging. - Added a
slog.Logger
tohttp.Request.Context()
. - Added a
slog.Logger
tojson.Request
.
- PanicMiddleware no longer writes response code (to avoid panic from duplicate write).
- PanicMiddleware prints stack trace to stderr.
- Configured
http.Server
with no timeouts. - Added
AdjustServerFn
toapi.Server
that allows configuration of the underlyinghttp.Server
.
- Added
errors.CaptureMiddleware
to report API errors. - Added macros to
errors
for creating path/querystring/payload parse errors. - Added request parsers that automate parsing and error wrapping.
- Improved
recovery.PanicMiddleware
to injectPanicError
(adheres toerror
) instead ofinterface{}
. PanicError
contains stack trace asStackTrace() []byte
.- Added
jwt.ClaimsMiddleware[T]
which retrieves JWT token from request, then parses the token into custom claims.
- Reimplemented
intercept.Middleware
to usehttpsnoop
.
- Added
MiddlewareChain
to create a set of middlewares without using a router. This is helpful to apply middleware to a single HTTP handler.
- Added
ErrorCode
toApiError
to emit application-specific error codes. - Changed
BadRequestError.Details
from[]string
tomap[string]string
- Added
errors.ObscureInteralErrorsMiddleware
to prevent sensitive errors from reaching users.- A developer can optionally log the original error message to logs.
- Refactor
ValidationErrors
to a slice for easier interaction. - Added helpers to
ValidationErrors
to swap between map and slice.
- Reporting json encoding errors to logs when sending json response.
- Fixed
ApiError
from hiding injectedErr
.
- Added
NewApiError
andNewBadRequestError
for easier error construction.
- Improved formatting of
errors.BadRequestError
.
- Added support for
errors
package injsonapi
package.
- Aligned
SendError(error)
injsonapi
package withjson
package.
- Added
captureBody
toggle onintercept.Middleware
to prevent capturing body if only intercepting status code/response duration.
- Added
http.Hijacker
pass-through for all response writers (includingintercept.Middleware
).
- Added
LaunchTLS
toServer
.
- Added
errors
package for default error formats.
- Replace panic middleware with custom and added user-supplied fn.
- Fixed CORS preflight from responding with 405 (Method Not Allowed) when a route was not registered.
- Added
logging.FallbackBehavior
.
- Fix busted go version.
- Replaced logging middleware with
intercept.Middleware
and logging macros.
- Fixed emission of errors through
jsonapi
interfaces.
- Added
jwt.Middleware()
to parse, but not verify incoming jwt token inAuthorization
header asBearer
token.
- Add
jsonapi
package to support JSONAPI.
- Fixed
EndpointGroup
prefix.
- Added
EndpointGroup
to locate several endpoints under a single prefixed path.
- Fixed bug in
AuthenticateMiddleware
prohibiting upstream proxying when error occurs.
- Added
auth
package withAuthenticateMiddleware
andAuthorizeMiddleware
.
- Added support for
Access-Control-Allow-Credentials
for cors middleware.- By default, this is set to
true
- By default, this is set to
- Amended endpoint logger to log outgoing data for 4xx, 5xx responses
- Providing default CORS setup that works properly
- Providing mechanism to flow NotFound and MethodNotAllowed through middlewares
- Setting up
app1
example to log NotFound and MethodNotAllowed and utilize default CORS setup
- Added
standard.NewEnpoint
helper to make concise syntax.
- Rebuilt entire library to be simpler and not obscure golang http constructs.
- Added
gzip
,recovery
middleware - Added
options
endpoint
- BREAKING: Removed
Unlogged()
from endpoints. - Added support for middleware
- Added endpoint logger to migrate endpoint logging to middleware.
- Added support for reading query string from request.
- Added
Raw.Endpoint
, allowing ahttp.HandlerFunc
to be used as anEndpoint
.
- Added
Endpoints
with a helperPrint
.
- Added ability to not log requests to an endpoint. Useful for health endpoints that are repeatedly hit.
- Using t.Run to run tests.
- Rebuilt api server contextual wrapping.
- Fixed response header
Content-Type
toapplication/json
.
- Refactoring logging of request.
FEATURES:
- Logging duration of request.
FEATURES:
- Initial implementation of go-api.
- Implemented json endpoints.