kwhitley / itty-router

A little router.
MIT License
1.69k stars 77 forks source link

DRAFT: baseless nested routers working (appx +50 bytes) #208

Closed kwhitley closed 3 months ago

kwhitley commented 6 months ago

Description

This adds a new way to nest routers, by passing the entire router as a handler. With this method, child routers do not need explicit base paths set.

const child = Router().get('/', () => 'child')

const parent = Router()
                 .get('/', () => 'parent')
                 .all('/child/*', child)

Notes

Type of Change (select one and follow subtasks)

kwhitley commented 3 months ago

This adds support for a few simple scenarios, while still requiring complex explanations/bypasses for more complex ones. In the end, that is likely not worth the bytes.

kwhitley commented 3 months ago

Closing this one for now until we are able to achieve the desired effect: