Skip to content

Update documentation for error-returning handlers and new serialization #30

@FumingPower3925

Description

@FumingPower3925

Breaking change in celeris core

The HandlerFunc type has changed from func(*Context) to func(*Context) error in v1.0.0.

Documentation updates needed

All code examples must use the new signature:

Before:

s.GET("/hello", func(c *celeris.Context) {
    c.String(200, "Hello, World!")
})

After:

s.GET("/hello", func(c *celeris.Context) error {
    return c.String(200, "Hello, World!")
})

New features to document

  1. Error-returning handlers — handlers return error, c.Next() returns error
  2. HTTPError typeceleris.NewHTTPError(code, message) for structured errors
  3. Error handling in middlewareerr := c.Next() to intercept downstream errors
  4. Unhandled error safety net*HTTPError → writes Code+Message; bare error → 500
  5. XML serializationc.XML(code, v) response method
  6. Content-type-aware bindingc.Bind(v) auto-detects JSON/XML from Content-Type
  7. Explicit bindingc.BindJSON(), c.BindXML()
  8. Content negotiationc.Negotiate(), c.Respond() for auto-format selection
  9. Response capturec.CaptureResponse(), c.ResponseBody(), c.ResponseContentType()
  10. Route-level middlewares.GET("/path", handler).Use(middleware)

Note: ProtoBuf is NOT in core — available via goceleris/middlewares.

Reference

The core doc.go and README.md have already been updated with the new patterns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions