2
votes

How is it possible to enable custom HTTP verbs in an elixir application using the phoenix framework?

I can see how the macros get, post etc. are created in https://github.com/phoenixframework/phoenix/blob/master/lib/phoenix/router.ex#L320-L334. However, probably because of the nested macro architecture that is being used, I was not able to implement a custom HTTP verb, say bla using a router definition like that:

Phoenix.Router.Scope.route Ical.Router, :match, :bla, "/bla", PageController, :bla, []

While not causing an compiler error, a 404 is produced when performing an BLA /bla HTTP/1.1 request.

It does not even work when trying to simulate the GET behaviour with

Phoenix.Router.Scope.route Ical.Router, :match, :get, "/bla", PageController, :bla, []

Any hints on this would be very much appreciated!

1
Phoenix.Router.Scope.route is not documented, therefore it is private to the Phoenix webframework. Please don't call private functions, Phoenix can change that at any time and your code will break. Why do you want a custom HTTP verb? There are many trade-offs involved in doing so and therefore it should not be done lightly: programmers.stackexchange.com/questions/193821/…José Valim
Hello José, thank you for your comment. The intention of custom HTTP verbs was indeed not to invent a new communication protocol, but exploring to implement a subset of the WebDAV/CalDAV protocols. To my understanding, as I am only in the beginning of my research, custom HTTP verbs are needed for that.iStefo
So it is best to open up an issue in Phoenix issues tracker. I don't think we support them for now. :)José Valim

1 Answers

0
votes

Alright, I found a way to implement this using the application's config files.

The simple implementation and the future of this case can be seen in this pull request: https://github.com/phoenixframework/phoenix/pull/1234.