Skip to content

Named path parameters #1587

@bugdea1er

Description

@bugdea1er

For now, the server is putting the responsibility on me to write the correct regex and duplicate it in every path. For example, it is not enough to use (.+) for project ID for paths

GET /projects/11/files HTTP 1.1

and

GET /projects/11 HTTP 1.1

since it would also require to bind them to the server in the proper order.

I suggest to adopt some familiar syntax for parameters in paths (like, {id} or :id) and do not require to write regexes from the user:

srv.Get("/projects/{id}/item", handler);

Such syntax would also allow me to get parameter values by the key instead of the order with some kind of operator[]:

void handler(auto req, auto res) {
  auto project_id = req["id"];
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions