koajs / joi-router

Configurable, input and output validated routing for koa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

mamatsunami opened this issue · comments

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

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

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 ;)