Skip to content

Support optional last paramΒ #25

@MarkoMackic

Description

@MarkoMackic

Let's suppose you have common handler for REST type API on some resource,
like /companies/.

So usual request pattern is :

  • GET /companies(/?) - > get all companies
  • GET /companies/:id -> get specific company
  • PUT/POST/PATH/DELETE /companies/:id -> do something to specific company

Now all of the work can be done by the same handler , if it knows if :id is present.

I'm suggesting introduction of optional last param, e.g.
router.insert("/companies/:id?", whatever);

  • accepts route /companies/
  • accepts route /companies/some_id

router.insert("/companies/*catch_all?", whatever)

  • same as above for route without param
  • and general catchall behaviour is applied if param exists

Optional params should be supported only if they are in the route end ( which is obvious ) .

This would be easier than writing double insert in code that uses the library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions