boywithkeyboard-archive / cheetah1

A framework for the modern web. (NO LONGER MAINTAINED)
https://cheetah.mod.land
Apache License 2.0
192 stars 1 forks source link

Helpers to register custom routes from extension #134

Closed fecony closed 1 year ago

fecony commented 1 year ago

Would be helpful to make a way to add new routes from custom extension to extend code Maybe developers could use it to simply add extension like .use(healthcheck()) that would register it's own route /healthcheck and add some logic before that

For now it's kinda possible to do by adding it to app.routes Set, but it can be improved to make it as easy as app.routes.add('GET', '/healtcheck, (c) => '💚') or with .get / .post methods

boywithkeyboard commented 1 year ago

It would work like that:

app.routes.add(['GET', '/', new RegExp('path to regexp'), [() => 'Hello World']])