koajs / joi-router

Configurable, input and output validated routing for koa
MIT License
450 stars 96 forks source link

[question] How to implements HTTP 405 and 501 support ? #54

Closed mamatsunami closed 7 years ago

mamatsunami commented 7 years ago

Hi,

I try to use ".allowedMethods()" (from koa-router) on a koa-joi-router instance, but it is undefined. The list of features includes "HTTP 405 and 501 support", is it really implemented ?

Thanks

Nicholaiii commented 7 years ago

Internally koa-joi-router uses the npm module "methods" that wraps around http.METHODS. You can use either to determine available methods.

mamatsunami commented 7 years ago

Oh ! I didn't see that a related koa-router instance is available on the routerproperty of a koa-joi-router instance. From the main example in README.md, to activate 405/501 support, just got to do :

...

const app = new koa();
app.use(public.middleware());
app.use(public.router.allowedMethods());
app.listen(3000);

Thanks for your time @Nicholaiii ;)