Skip to content

feat: Add generic request binding and cool colored logger#8

Merged
bernardoforcillo merged 4 commits into
mainfrom
jules-cool-features-6941033057768301019
Jan 3, 2026
Merged

feat: Add generic request binding and cool colored logger#8
bernardoforcillo merged 4 commits into
mainfrom
jules-cool-features-6941033057768301019

Conversation

@google-labs-jules
Copy link
Copy Markdown
Contributor

This PR introduces two "cool" features to Amaro:

  1. Generic Request Binding: Adds BindJSON, BindQuery, and BindForm helper methods to Context. These methods use reflection to map request data (JSON body, query parameters, form data) directly to user-defined structs. The binding logic (bindData) supports a wide range of types including all integer/uint variants, floats, complex numbers, booleans, strings, pointers to these types, and slices of these types.
  2. Colored Logger: Upgrades the default Logger middleware to output visually distinct logs using ANSI colors. Status codes are color-coded (Green for 2xx, White for 3xx, Yellow for 4xx, Red for 5xx), and HTTP methods also get their own colors. The log format includes the status code, method, path, and latency.

Tests were added for the new binding capabilities and the logger middleware was verified.


PR created automatically by Jules for task 6941033057768301019 started by @bernardoforcillo

- Add BindJSON, BindQuery, BindForm to Context with comprehensive reflection support (floats, complex, slices, pointers).
- Enhance Logger middleware with ANSI colors and structured output (Method, Path, Status, Latency).
- Add tests for request binding and logger middleware.
@google-labs-jules
Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Add `Routes()` to `Router` interface and implement in `TrieRouter` for introspection.
- Add validation tags (`required`, `min`, `max`) to `Bind*` methods.
- Ensure `Bind*` methods safely handle non-pointer or nil inputs by returning errors.
- Update `loggingResponseWriter` to implement `http.Flusher`.
- Add comprehensive tests for validation, introspection, and binding safety.
- Add `addons/htmx` for HTMX helpers (Is, Trigger, Redirect, etc).
- Enhance `Recovery` middleware with `WithHTMLDebug(bool)` option.
- Add simple but pretty HTML template for panic debug page.
- Verified with tests.
- Add `app.Test(req)` helper method to simplify integration testing for developers.
- Removed Swagger UI addon based on user feedback.
- Ensured all tests pass for new features (HTMX, Binding, Recovery).
@bernardoforcillo bernardoforcillo marked this pull request as ready for review January 3, 2026 14:26
@bernardoforcillo bernardoforcillo merged commit d5522b8 into main Jan 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant