Skip to content

Using route :any causes OPTIONS and HEAD requests to fail #1056

Closed
@ekampp

Description

@ekampp

According to the documentation, any GET endpoint also serves OPTIONS and HEAD requests.

I would expect these to be hit before the route :any at the bottom of my api. But this isn't the case.

Is this a bug or intentional? If it's intentional, what's the right way to catch stray requests without overriding OPTIONS and HEAD for the real endpoints?

route :any, '*path' do
  raise NotFound, 'Path not NotFound'
end

Here is a demo api. I would expect this request to return the Allow header for the /names endpoint. But instead it return I'm not here, which means it hits the route :any fallback.

OPTIONS /names

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