Skip to content

Releases: fulldump/box

OpenAPI enhancements

16 Jul 01:10

Choose a tag to compare

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

28 Mar 10:37

Choose a tag to compare

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

03 Mar 00:54

Choose a tag to compare

  • Add support for Request.PathValue
  • Remove ambiguity when path variables contains the operation separator :

Configurable 404 and 405

03 Mar 00:51

Choose a tag to compare

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

07 Nov 17:26

Choose a tag to compare

v0.4.3

fix: proper context replacement

Type alias for I and H

24 Oct 15:49

Choose a tag to compare

This allow third parties to create compatible interceptors without coupling with box.

v0.4.1 Fix infinite recursion in openapi

31 May 22:24

Choose a tag to compare

Fix infinite recursion in openapi and support time.Time

Add OpenAPI trendy spec

18 May 04:49

Choose a tag to compare

Add new package to generate OpenAPI spec based on the information the API already have.

Sugar syntax

27 Jan 00:51

Choose a tag to compare

Add some aliases and shortcuts syntax sugar to make tiny projects easy to read

RawPaths supported

25 Apr 15:35
9fdb6fa

Choose a tag to compare

v0.1.3

fix: use Request.RawPath (unescaped) to resolve routes instead of Req…