Skip to content

Conversation

@vinniefalco
Copy link
Member

No description provided.

@cppalliance-bot
Copy link

cppalliance-bot commented Dec 16, 2025

An automated preview of the documentation is available at https://218.http-proto.prtest.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2025-12-17 15:28:50 UTC

@cppalliance-bot
Copy link

cppalliance-bot commented Dec 16, 2025

Copy link
Contributor

@MungoG MungoG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it does feel like the documentation probably belongs in github.com/cppalliance/beast2 rather than github.com/cppalliance/http_proto

|Close the connection after sending any response.

|`route::complete`
|Request fully handled; no response to send.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear from the docs what happens as a result of returning this. Suggest including its use into an existing (or new) example.

|Continue to the next handler in the chain.

|`route::next_route`
|Skip remaining handlers in this route, try the next route.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an example or more description.

Comment on lines +138 to +161
The router tries each matching route in registration order. If a handler
returns `route::next`, the router continues to the next handler. If all
handlers return `route::next`, dispatch returns `route::next` to indicate
no handler produced a response.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear from this text what happens if the final handler returns route_next. Does it get translated to next or does this function also have to handle route_next.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this needs to be explained. the call to router::dispatch will return route::next which is an error

== Handler Chaining

Multiple handlers can be registered for the same route. They execute in
order until one returns something other than `route::next`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or, presumably, route::next_route

idiomatic C++

- In the C++ router, route handlers are declarative rather than imperative. They
package up the response using a Sans-IO API. Beast2 handles the sesnding
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
package up the response using a Sans-IO API. Beast2 handles the sesnding
package up the response using a Sans-IO API. Beast2 handles the sending

Add initial documentation for the Express.js-style router API covering:
- Handler signatures and return values
- Adding routes with add() and all()
- Fluent route() interface
- Dispatching requests
- Handler chaining
- Path patterns
- Router options

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@vinniefalco
Copy link
Member Author

it does feel like the documentation probably belongs in github.com/cppalliance/beast2 rather than github.com/cppalliance/http_proto

If we do that, then what will the http-proto docs have? basic_router is in http_proto

router.add(method::post, "/users", create_user);
router.add(method::get, "/users/:id", get_user);
router.add(method::put, "/users/:id", update_user);
router.add(method::delete_, "/users/:id", delete_user);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

(Of course - me being a complete idiot)

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.

3 participants