Closed abovedave closed 3 years ago
1) when we load each of the routes specified in page.json files, we use app.use
which allows any method through. GET is handled by default in the controller, POST requests must be handled by events. We could add a property to a route that indicates the method it corresponds to, and deal with that somewhere in the route validation function.
2) we can certainly implement methods for each verb, that's easy enough to do. That would mean in middleware we could do:
app.post('/foo/post', (req, res, next) => {
return res.end(JSON.stringify(req.body))
})
app.get('/foo/get', (req, res, next) => {
return res.end(JSON.stringify(req.params))
})
This would allow middleware to handle a POST, rather than an event. However, the middleware doesn't have access to page data, as the request knows nothing about events or datasources and never goes through the controller - because we're loading a route + handler that is unrelated to any page specification.
@abovedave what is the refresh
argument you've added? A function with 4 arguments is treated as an error handler.
Yes I think it was the refresh
breaking it 🙈
Still, would be useful to have get
and post
like that for shared routing
Currently page's take precedence over middleware. Page
Middleware
Couple of options:
page.json
config which requests to respond to?app.get(
andapp.post(
similar to Express?