Skip to content

Wrong Patern is Generated for root path in OAS Spec for http.ServeMux #1952

@snoweuph

Description

@snoweuph

Using the root path /: directly in an OAS spec, results in the generator registering it with the literal "/" which is wrong.

It should instead be "/{$}"

This is because, the go http.ServeMux is interpreting trailing / as a wildcard match.

This means that:

  • / matches anything
  • /cake/ matches anything starting with /cake

The result is that you won't be able to add another handler for all unmatched requests and that the handler for /: will match any unmatched path

The Current Workaround, I'm using for this, is: /\x7B$\x7D: as the root path in my OAS spec.
go will convert these correctly at comp time.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions