Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More elaborate routing (e.g. match only ints, etc.) #122

Open
aantron opened this issue Jul 9, 2021 · 5 comments
Open

More elaborate routing (e.g. match only ints, etc.) #122

aantron opened this issue Jul 9, 2021 · 5 comments

Comments

@aantron
Copy link
Owner

aantron commented Jul 9, 2021

For example, allow a way to check that :id in /blah/:id is an integer before matching the route.

cc @jsthomas @c-cube for interest.

@aantron
Copy link
Owner Author

aantron commented Jul 10, 2021

dream-routes from @ulrikstrid adapts @anuragsoni's Routes to Dream:

let () =
  Dream.run
  @@ Dream.logger
  @@ Dream_routes.routes Routes.[
    empty @--> (fun _request ->
      Dream.html "Good morning, world!");

    s "echo" / int /? nil @--> (fun integer _request ->
        Dream.html @@ Printf.sprintf "integer: %i" integer);

    s "echo" / str /? nil @--> (fun word _request ->
      Dream.html word);
  ]
  @@ Dream.not_found

@thangngoc89
Copy link
Contributor

Would you like a PR to Community Projects section in README?

@ulrikstrid
Copy link
Collaborator

Note that dream-routes does not yet handle different methods and we might need to discuss a nice API for that.

@thangngoc89 I think the community projects is a list of vetted projects that are actually recommended. So I guess a issue to ask for inclusion is what should happen 🙂

@aantron
Copy link
Owner Author

aantron commented Jul 10, 2021

I think after dream-routes supports methods, and after a bit of review, we can add it to the list.

@ulrikstrid
Copy link
Collaborator

See ulrikstrid/dream-routes#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants