sstur / nbit

A zero-dependency, strongly-typed web framework for Bun, Node and Cloudflare workers
65 stars 4 forks source link

Support for custom request methods? #9

Closed ImLunaHey closed 1 year ago

ImLunaHey commented 1 year ago

I noticed there's no way to define a custom request method.

Is this something that could possibly be added?

sstur commented 1 year ago

What would be an example of a custom request method, you mean like instead of GET|PUT|POST|DELETE you'd want something like FOO?

Do other frameworks support this? What would be a use case for such a thing?

ImLunaHey commented 1 year ago

Most others do in one way or another.

WebDAV servers for example uses non-standard methods like MKCOL and PROPFIND. I've run into a few times in the past where I've needed this.

A solution for now would be to use * and then do my own checks on request.method.

sstur commented 1 year ago

Oh, interesting. I haven't thought about WebDAV in a very long time, but you're right, that's a legit use case for strange request methods.

I think you're right, the workaround for now is to use the *, but I'll see about adding support for any arbitrary string like so:

  app.route('MKCOL', '/webdav', (request) => {
    return new Response(...);
  }),
sstur commented 1 year ago

Done. This is now possible in v0.10.