Skip to content

pages handled by a 404.sql should not redirect to add a trailing slash #971

@olivierauverlot

Description

@olivierauverlot

I am working on a REST API with SQLPage. I noticed a problem with the use of the DELETE verb. If I do not put a / character at the end of the URL, I get a 301 Moved Permanently error. I do not have this issue with the other HTTP verbs (GET, PUT, POST, PATCH).

The following code is in the file /api/v1/users/404.sql.

SELECT 'json' AS component;
SELECT 
    CASE sqlpage.request_method()
        WHEN 'GET' THEN 'READ'
        WHEN 'DELETE' THEN 'REMOVE'
    END AS value;

You can reproduce the problem with these examples.

GET http://localhost:8080/api/v1/users

###
# Error 301 Moved Permanently ?
DELETE http://localhost:8080/api/v1/users/42

###
# works fine !
DELETE http://localhost:8080/api/v1/users/42/

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions