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 Protocolssince this is terminal. This matchesnet/httpbehavior.
WriteHeadercan again be used in theResponseWriter.Beforecallback 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
ResponseWriternow only implementshttpinterfaces (Flusher,Hijacker,CloseNotifier) if the wrappedhttp.ResponseWriterdoes. This is a breaking change to makeResponseWriter's interface support more accurate
ResponseWriternow implementsio.ReaderFromto more efficiently send responses viaio.Copy
- Fixed Go module name for v2
- Recovery middleware now checks that
Formatteris notnilbefore 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 originalNegroniinstance ifUseis called on the newNegroniinstance
Recovery.LogStackwas added to control whether the stacktrace is logged for panics
Loggermiddleware now correctly handles paths containing a%instead of trying to treat it as a format specifier
With()helper for building a newNegronistruct chaining handlers from existingNegronistructs- Format log output in
Loggermiddleware via a configurabletext/templatestring injectable via.SetFormat. AddedLoggerDefaultFormatandLoggerDefaultDateFormatto configure the default template and date format used by theLoggermiddleware. - Support for HTTP/2 pusher support via
http.Pusherinterface for Go 1.8+. WrapFuncto converthttp.HandlerFuncinto anegroni.HandlerFormatterfield added toRecoverymiddleware to allow configuring howpanics are output. Default ofTextFormatter(how it was output in0.2.0) used.HTMLPanicFormatteralso added to allow easy outputing ofpanics as HTML.
Written()correct returnsfalseif no response header has been written- Only implement
http.CloseNotifierwith thenegroni.ResponseWriterif the underlyinghttp.ResponseWriterimplements it (previously would always implement it and panic if the underlyinghttp.ResponseWriterdid not.
- Set default status to
0in the case that no handler writes status -- was previously200(in 0.2.0, before that it was0so this reestablishes that behavior) - Catch
panics thrown by callbacks provided to theRecoveryhandler - Recovery middleware will set
text/plaincontent-type if none is set ALoggerinterface to allow custom logger outputs to be used with theLoggermiddleware. Changes embeded field innegroni.LoggerfromLoggertoALogger.- Default
Loggermiddleware output changed to be more structure and verbose (also now configurable, seeAdded) - Automatically bind to port specified in
$PORTin.Run()if an address is not passed in. Fall back to binding to:8080if no address specified (configuable viaDefaultAddress). PanicHandlerFuncadded toRecoverymiddleware to enhance custom handling ofpanics by providing additional information to the handler including the stack and thehttp.Request.Recovery.ErrorHandlerFuncwas 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
Recoveryhandler was bumped to 8k Negroni.UseFuncto push another handler onto the chain
- Set the status before calling
beforeFuncsso the information is available to them - Set default status to
200in the case that no handler writes status -- was previously0 - Panic if
nilhandler is given tonegroni.Use
- Initial implementation.