Skip to content

Allow optional path segments #1054

@vmalloc

Description

@vmalloc

I was wondering how to implement a query for either a collection or a subresource, using the same handler. For example, say we have /products and /products/{product_id} -- it is currently impossible to manage both in the same handler conveniently.

I was wondering if it could be possible to use web::Path<Option<String>> for such cases, and have the handler check if a product id was specified in the URL. If that sounds reasonable I can try and craft a PR for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions