Skip to content

New feature : Support custom http verbs #3535

@stephane-benoist

Description

@stephane-benoist

It can be useful to allow custom verbs with something like hx-custom-verb-my_custom_verb attribute (and probably a configuration to push the authorized verbs)

The aim is to have way more explicit REST API

Take into account the simple case of changing a password :
Let say you PUT on /user/1, you have to check if their is a new password and update it, but what should you do if their is a change in name too ? Is it an allowed action ? Should you expect 2 different kind of payload ?
You can also PUT on /user/1/change-password, but you do not manipulate resources anymore as your URI.

The fact is you can bend REST to believe it work with the "basic" HTTP verbs, but when you do more than just CRUD, you soon reach your limit and compromise strongly the idea of CRUD or HATEOAS...
The HTTP specification allow use custom verbs and the implementation seems simple (I have something with working test with like +600 characters in htmx.js, that means +0.3%)
I think it will be rather difficult to add consistent behaviour with the rest of the verbs by doing it in an extension rather than in the main project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions