delvedor / find-my-way

A crazy fast HTTP router

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add constraint outside the constructor

matthyk opened this issue · comments

Currently, constraints can only be added when creating the FindMyWay instance. It would be very useful to be able to add more constraints later via a method like addConstraint. With regard to Fastify, this would allow plugins to add constraints without the developer having to specify the constraint itself when creating the Fastify instance.

const router = require('find-my-way')()

router.addConstraint(...)

Is this even implementable and if so is it desirable to have such functionality?

I don't see any problem with adding this. Sounds like a good idea.

Nice! Then I'll try to implement it!