Making router agnostic about making urls
Earlier the router was generating fully qualified URLS for a given domain. Instead, now it becomes agnostic about it and instead exposes the API to lookup routes and a helper method to make url from the looked up route.
Earlier
router.get('/posts/:id', handler).domain('blog.adonisjs.com')
router.makeUrl('/posts/:id', { params: { id: 1 } })
// returns: //blog.adonisjs.com/posts/1
Now
import { makeUrl } from '@poppinss/http-server'
const route = router.lookup('/posts/:id')
makeUrl(route.pattern, { params: { id: 1 } })
// returns /posts/1
With the newer API you can decide
- If you want to append a domain or not.
- Decide which protocol to use