chi

Chi

Specific best practices and architectural patterns when working with Chi.

Details

Language / Topic
goGo
Category
framework

Rules

balanced

Chi

- Use `chi.NewRouter()` with `r.Route()` for nested route groups. Apply middleware with `r.Use()` — chi middleware is standard `net/http` compatible. Use `chi.URLParam(r, "id")` for path parameters.

Chi

- Use `chi.NewRouter()` with `r.Route()` for nested route groups. Apply middleware with `r.Use()` — chi middleware is standard `net/http` compatible. Use `chi.URLParam(r, "id")` for path parameters.
- Use `chi/middleware` package for common middleware: Logger, Recoverer, RequestID, RealIP, Timeout. Group routes with `r.Group()` for shared middleware (e.g., auth). Use `r.Mount()` to compose sub-routers. Return JSON with `render.JSON(w, r, data)` from `chi/render`. Use `r.With()` for inline middleware on specific routes.