All notable changes to this project will be documented in this file starting from version v1.0.0. This project adheres to Semantic Versioning.
Changed:
- Add
gear.ThresholdCompress
instead ofgithub.com/teambition/compressible-go
. - Update dependencies.
Changed:
- Add gearproxy as example.
Changed:
- Update dependencies.
- Add a const
MIMEApplicationCBOR
.
Changed:
- Improve gear.Context with generics.
- Add
gear.State
for passing information through middleware and handlers. - Add functions:
func CtxWith[T any](parent context.Context, v *T) context.Context
func CtxValue[T any](ctx context.Context) *T
func CtxDoIf[T any, TI isValid[T]](ctx context.Context, fn func(v *T))
Fixed:
- Fix gear.ValuesToStruct for slice type.
Changed:
- Support h2c, the non-TLS version of HTTP/2
Fixed:
- Fix favicon middleware.
Changed:
- update trie-mux mod for issue #54. Your routing may be affected!
Changed:
- update trie-mux.
- add Log.KV method.
Changed:
- add SetGraceTimeout option.
- clear mod.
Changed:
- Remove ctx.Get and ctx.Set methods.
- Change Log structure fields: "time" -> "duration"; "timestamp" -> "time".
Changed:
- Add app.ServeWithContext method.
Changed:
- Update dependence.
Changed:
- Add gear.MIMEApplicationSchemaGraphQL constant.
- Enlarge Error' Stack trace buffer size.
Fixed:
- Fix ctx.ParseBody' error code.
Changed:
- Add gear.ErrorResponse struct that represents error response like JSON-RPC2 or Google cloud API.
- Add gear.RenderErrorResponse function that render error with ErrorResponse struct.
Fixed:
- Fix default SetRenderError function.
- Fix
xCanary
field in logging middleware.
Changed:
- Add gear.SetRenderError hook that convert error to raw response.
- Add gear.MIMEApplicationSchemaJSONLD MIME type.
Changed:
- Add default ReadHeaderTimeout, ReadTimeout, WriteTimeout and IdleTimeout for Server.
Fixed:
- Fix ctx.ParseURL for empty query.
Fixed:
- Fix ctx.WithContext: sets the context to underlying request object.
Changed:
- Add ctx.Scheme() instead of ctx.Protocol().
Fixed:
- Fix ctx.Protocol() and ctx.IP() for proxy.
Changed:
- Add request body and response body to access log when 500 error.
Fixed:
- Fix start time error for development logging.
Changed:
- Add "X-Canary" Header.
- Add ctx.StartAt property.
- Add ctx.GetHeaders method.
Changed:
- Add gear.App.ListenWithContext method.
- Add gear.ContextWithSignal function.
- Add logging.SetLoggerLevel function.
Changed:
- Improve misdirected response with message (421).
Fixed:
- Fix error's stack.
Fixed:
- Fix error's stack.
Changed:
- Remove "application/x-www-form-urlencoded" supporting from DefaultBodyParser.
Fixed:
- Fix logging middleware: fix time format.
- Fix logging middleware: change severity level to lowercase (https://en.wikipedia.org/wiki/Syslog).
Fixed:
- Fix logging middleware: support JSON log.
Changed:
- Update logging middleware: support JSON log.
Fixed:
- Fix DefaultBodyParser's mediaType.
Fixed:
- Allow add "after hook" and "end hook" after context ended but before header wrote.
Fixed:
- Panic in "end hook" will be recovered.
Fixed:
- Fix gear.Response #49
Changed:
- Remove
501 Not Implemented
for gear.Router.
Changed:
- Update logging middleware: add more log info.
Changed:
- Add ctx.OkHTML, ctx.OkJSON, ctx.OkXML, ctx.OkSend, ctx.OkRender, ctx.OkStream
Fixed:
- Fix and improve ctx.ParseURL
Changed:
- Add go.mod
Changed:
- Add GetRouterPatternFromCtx function
Changed:
- Add x-request-XXX to header filter whitelist
Fixed:
- Fix gear.SetOnError hook.
Changed:
- ctx.Error and ctx.ErrorStatus will not trigger gear.SetOnError hook now.
- Add gear.SetParseError hook.
Changed:
- Add requestid middleware.
- Improve json error message.
Changed:
- Add ParseLevel function to logging middleware.
Changed:
- Add MIMEApplicationYAML (for OpenAPI 3) and MIMEApplicationTOML, remove MIMEApplicationMsgpack.
Changed:
- Improve error message for gear.Router.
Fixed:
- Fix logger timestamp format.
Changed:
- Add X-Request-ID header to log.
Changed:
- Add Referer and Origin header to log.
- Add gRPC midddleware.
Fixed:
- Fix logging.
Changed:
- Add SetTrustedProxy setting.
Changed:
- Add status code 499 ClientClosedRequest and use it for context canceled error.
Fixed:
- Change and fix ctx.IP().
Fixed:
- Make ctx.ParseBody support application/jrd+json, application/jose+json and so on.
Changed:
- Add ctx.Send method.
Fixed:
- Fix gear.ContentDisposition for IE7/8.
Changed:
- Add HTTP Status code 103 Early Hints.
Fixed:
- Fix CORS middleware.
Changed:
- Improve logging.
Changed:
- Add GetRouterNodeFromCtx function.
Changed:
- Add Decompress function; ctx.ParseBody support compress content.
Changed:
- Some methods of App, Router, and Logger return itself for chain-style.
Changed:
- Add ctx.MustAny method and logger.SetTo method.
Changed:
- Add ctx.LogErr method.
Changed:
- Return error when recalling end method.
Changed:
- Add Log.With method.
Changed:
- Add Options.OnlyFiles for static middleware.
Fixed:
- Fix logging. Add more test.
Fixed:
- Fix error logging.
Changed:
- Add
Includes
option to static middleware.
Changed:
- Change ctx.Get to ctx.GetHeader; Change ctx.Set to ctx.SetHeader.
Fixed:
- Fix empty status detecting.
Fixed:
- Support Referrer header.
Fixed:
- Fix const errors.
Fixed:
- Fix gear.ValuesToStruct.
Changed:
- Add Error.WithErr(name string).
Changed:
- Update logging middleware: print time with brackets.
Changed:
- Update defaultHeaderFilterReg for error response.
- Make end-hooks running in defer func.
Changed:
- Add a QUIC example.
Fixed:
- Fix logging's development consume function.
Changed:
- Add gear.LoggerFilterWriter to filter unnecessary server errors.
Fixed:
- Fix root path for router with namepace.
Fixed:
- Fix logging middleware, issue 24.
Changed:
- Add gear.SetServerName setting.
Changed:
- Change development logger format to "Common Log Format".
Changed:
- Improve gear.Error and logging.
Changed:
- Improve ValuesToStruct function.
Fixed:
- Add
X-Ratelimit-
todefaultHeaderFilterReg
.
Changed:
- Run "end hooks" in a goroutine, in order to not block current process.
Changed:
- Add
Error.WithStack(skip ...int) *Error
andError.WithMsgf(format string, args ...any) *Error
.
Changed:
- Add
logging.Debugf(format string, args ...any)
.
Changed:
- Add
ctx.Res.Body()
method.
Changed:
- Add
ctx.ParseURL(body BodyTemplate)
method. - Change
gear.FormToStruct(map[string][]string, any) error
togear.ValuesToStruct(map[string][]string, any, string) error
gear.ValuesToStruct
support pointer fields, soctx.ParseURL
andctx.ParseBody
support pointer fields too.
Fixed:
- Fix for multi-routers
Changed:
- Improve
ctx.IP()
- Add
ctx.Protocol()
Changed:
- Remove unnecessary error constants.
Changed:
- Refactor
gear.Error
type. It is more powerful!
Changed:
- Ignore
"context canceled"
error. - Add more examples.
Changed:
- Support Form body parse.
- Improve project structure.
Changed:
- Add
Response.Status()
,Response.Type()
. Context.Status
andContext.Type
will not return value now.
Changed:
- Improve code.
Fixed:
- Fix Logging middleware #19 .
Changed:
- Add more document.
Changed:
- Change default BodyParser's
MaxBytes
to2MB
. - Add more document.
Changed:
- Simplify ctx.Timing method:
func (*Context) Timing(time.Duration, fn func(context.Context)) error
Fixed:
- Fix CORS middleware #17 .
Fixed:
- Fix logging middleware that should init structured log when start.
Fixed:
- Fix Context.WithContext method that maybe recursive.
Fixed:
- Fix Error.String() method that Error.Meta may be invalid utf-8 bytes.
Fixed:
- Fix and improve Content-Disposition which is used by ctx.Attachment.
- Update Readme document.