Rocket icon indicating copy to clipboard operation
Rocket copied to clipboard

[Feature Request] Allow route decorator to define a custom HTTP method.

Open mehcode opened this issue 8 years ago • 5 comments

Allow the generic route decorator to accept any method. I'd be okay with requiring quotes for non-standard methods.

#[route(FOO, path = "...")]

Or

#[route("FOO", path = "...")]

Key motivation for this is I have a colleague who uses https://tools.ietf.org/html/draft-snell-link-method-12 in his API definitions.

There are also a dozen more defined methods that aren't "standard HTTP". It's not reasonable for rocket to have first-class support for any method. I think this is a good middle ground.

mehcode avatar Mar 17 '17 00:03 mehcode

Hello everybody, has anyone given more thought to this? I need this feature, my use case is trying to create a webdav server in my app that can share my application contacts with phones/computers. WebDav makes use of a few custom methods like 'PROPFIND' & 'MKCOL' that i would need to be able to use.

I have found #619 but after reading the comments left by @SergioBenitez I'm not sure how to move forward with this. I agree that putting a String in Method is not the best idea, but i don't see a way to possibly use a &'static str there.

My idea is to create a feature gate (maybe named webdav_methods) that when enabled would add the webdav related http methods to the Methods enum. I don't know much about the internals of the route macros (route, get, post, etc.) but i don't think it would make much sense to provide a macro for these methods if they could be created with just the #[route(MKCOL, ...)] macro.

Here is a list of all the Extension Methods would be necessary for this feature

  • COPY
  • LOCK
  • MKCOL
  • MOVE
  • PROPFIND
  • PROPPATCH
  • UNLOCK

patrickisgreene avatar Nov 26 '20 21:11 patrickisgreene

Hello, any updates on this? I am very interested in supporting additional HTTP methods (if you don't want to support defining them via a string). My use case is to be able to declare routes supporting LOCK and UNLOCK methods

alexandrebouthinon avatar Jan 22 '22 00:01 alexandrebouthinon

any plans on this? would PRs be appreciated? basically, i'm not so much interested in custom methods, but including the standard methods (although not the HTTP 1.1 standard) added by other RFCs like webdav - like those listed here: https://webconcepts.info/concepts/http-method/

nanobot248 avatar Sep 15 '22 10:09 nanobot248

Me too. I need LOCK and UNLOCK methods. btw there is uses cases like a custom terraform http backend https://developer.hashicorp.com/terraform/language/settings/backends/http

I guess i will use the workaround for now!

Clivern avatar Feb 11 '23 19:02 Clivern

I agree, maybe a Custom(String) enum member could be added on the HttpMethod?

Jethril avatar Jun 03 '23 16:06 Jethril