Releases: fulldump/box
Releases · fulldump/box
OpenAPI enhancements
OpenAPI enhancements:
- Correct name for properties, now fields with tag "name,omitempty" are exported as "name" instead of "name,omitempty"
- Handle anonymous structs
- Paths with no methods are discarded
- Resources or Actions can be marked to not export
Custom Serializer/Deserializer
Use custom serializer and deserializer functions :D
b := NewBox()
b.Serializer = func(ctx context.Context, w io.Writer, v interface{}) error {
// Your custom code here:
resp := GetBoxContext(ctx).Response
resp.Header().Set("Content-Type", "application/json+customwrap")
resp.WriteHeader(http.StatusFound)
json.NewEncoder(w).Encode(map[string]interface{}{
"wrap": v,
})
return nil
}
b.Deserializer = func(ctx context.Context, r io.Reader, v interface{}) error {
// Your custom code here:
payload, err := io.ReadAll(r)
if err != nil {
return err
}
if len(payload) > 15 {
return ErrPayloadTooLong
}
return json.Unmarshal(payload, v)
}Unambiguity
- Add support for
Request.PathValue - Remove ambiguity when path variables contains the operation separator
:
Configurable 404 and 405
Make configurable HandleResourceNotFound and HandleMethodNotAllowed.
Examples:
b := NewBox()
b.HandleResourceNotFound = func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte("HEY! Not Found"))
}
b.HandleMethodNotAllowed = func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusMethodNotAllowed)
w.Write([]byte("HEY! Method Not Allowed"))
}Fix context overwrite
v0.4.3 fix: proper context replacement
Type alias for I and H
This allow third parties to create compatible interceptors without coupling with box.
v0.4.1 Fix infinite recursion in openapi
Fix infinite recursion in openapi and support time.Time
Add OpenAPI trendy spec
Add new package to generate OpenAPI spec based on the information the API already have.
Sugar syntax
Add some aliases and shortcuts syntax sugar to make tiny projects easy to read
RawPaths supported
v0.1.3 fix: use Request.RawPath (unescaped) to resolve routes instead of Req…