Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Consider making _scheme and _method a config option #5990

Copy link
Copy link
Closed
@Tobion

Description

@Tobion
Issue body actions

Currently configuring the _scheme and _method requirement in routes is pretty strange and also wrong in some cases. Current example:

route_name:
    pattern: /hello/{slug}
    hostname_pattern: {locale}.example.com
    requirements:
        locale: en|fr
        slug: \w+
        _scheme: HTTPS
        _method: GET|POST
    defaults:
        _controller: Foo:bar:baz

The problems are:

  1. variables in the requirement section reference placeholders. Except for _scheme and _method!
  2. these requirements allow regular expressions. But this is not true for _scheme and _method because many places of the routing component expect a delimited list like GET|POST. So normal regex like .+ does not work for them and breaks code.

My proposal:

route_name:
    pattern: /hello/{slug}
    hostname_pattern: {locale}.example.com
    schemes: HTTPS
    methods: [GET, POST]
    requirements:
        locale: en|fr
        slug: \w+
    defaults:
        _controller: Foo:bar:baz

This makes these scheme and method an option like pattern which is much more consistent as they are on the "same level" as the path pattern because all of them belong to the HTTP request (method + URL). One can also clearly define that not any regex is valid but only a single string or an array of allowed methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.