ATTN: This project uses semantic versioning.
- Writing an HTTP 1xx status codes no longer results in a 200 being sent in
addition given the expectation is that a follow-up status code will be written
later. The exception is
101 Switching Protocols
since this is terminal. This matchesnet/http
behavior.
WriteHeader
can again be used in theResponseWriter.Before
callback to set HTTP status codes
- Satisfy
http.ResponseController
(Go 1.20+)
- Replace multiple slashes at the beginning of a path with a single one to avoid open redirects
- Avoid updating
ResponseWriter.Status()
if the status has already been written whenResponseWriter.WriteHeader()
is called twice
ResponseWriter
now only implementshttp
interfaces (Flusher
,Hijacker
,CloseNotifier
) if the wrappedhttp.ResponseWriter
does. This is a breaking change to makeResponseWriter
's interface support more accurate
ResponseWriter
now implementsio.ReaderFrom
to more efficiently send responses viaio.Copy
- Fixed Go module name for v2
- Recovery middleware now checks that
Formatter
is notnil
before calling
Recovery.PrintStack
, when false, now also supresses the panic message in addition to supressing the stack trace
Negroni.With()
now copies handlers to avoid mutating the originalNegroni
instance ifUse
is called on the newNegroni
instance
Recovery.LogStack
was added to control whether the stacktrace is logged for panics
Logger
middleware now correctly handles paths containing a%
instead of trying to treat it as a format specifier
With()
helper for building a newNegroni
struct chaining handlers from existingNegroni
structs- Format log output in
Logger
middleware via a configurabletext/template
string injectable via.SetFormat
. AddedLoggerDefaultFormat
andLoggerDefaultDateFormat
to configure the default template and date format used by theLogger
middleware. - Support for HTTP/2 pusher support via
http.Pusher
interface for Go 1.8+. WrapFunc
to converthttp.HandlerFunc
into anegroni.Handler
Formatter
field added toRecovery
middleware to allow configuring howpanic
s are output. Default ofTextFormatter
(how it was output in0.2.0
) used.HTMLPanicFormatter
also added to allow easy outputing ofpanic
s as HTML.
Written()
correct returnsfalse
if no response header has been written- Only implement
http.CloseNotifier
with thenegroni.ResponseWriter
if the underlyinghttp.ResponseWriter
implements it (previously would always implement it and panic if the underlyinghttp.ResponseWriter
did not.
- Set default status to
0
in the case that no handler writes status -- was previously200
(in 0.2.0, before that it was0
so this reestablishes that behavior) - Catch
panic
s thrown by callbacks provided to theRecovery
handler - Recovery middleware will set
text/plain
content-type if none is set ALogger
interface to allow custom logger outputs to be used with theLogger
middleware. Changes embeded field innegroni.Logger
fromLogger
toALogger
.- Default
Logger
middleware output changed to be more structure and verbose (also now configurable, seeAdded
) - Automatically bind to port specified in
$PORT
in.Run()
if an address is not passed in. Fall back to binding to:8080
if no address specified (configuable viaDefaultAddress
). PanicHandlerFunc
added toRecovery
middleware to enhance custom handling ofpanic
s by providing additional information to the handler including the stack and thehttp.Request
.Recovery.ErrorHandlerFunc
was also added, but deprecated in favor of the newPanicHandlerFunc
.
0.2.0 - 2016-05-10
- Support for variadic handlers in
New()
- Added
Negroni.Handlers()
to fetch all of the handlers for a given chain - Allowed size in
Recovery
handler was bumped to 8k Negroni.UseFunc
to push another handler onto the chain
- Set the status before calling
beforeFuncs
so the information is available to them - Set default status to
200
in the case that no handler writes status -- was previously0
- Panic if
nil
handler is given tonegroni.Use
- Initial implementation.