trailsjs / trailpack-router

:package: Router. Aggregate and Configure Application Routes.
MIT License
12 stars 7 forks source link

The route handler must be in the form "Controller.handler" #1

Closed weyj4 closed 8 years ago

weyj4 commented 8 years ago

The relevant code is in the repo at lib/xfmr.js:61+.

Are we sure we want to limit handlers in this way? According to the Hapi docs, "Alternatively, handler can be assigned an object with a single key using the name of a registered handler type and value with the options passed to the registered handler".

This becomes necessary for instance when using the "inert" package (https://github.com/hapijs/inert) to serve a static directory (http://hapijs.com/tutorials/serving-files).

tjwebb commented 8 years ago

2) Get this sorted out and start serving a dist/ directory.

@weyj4 can you elaborate? this is re trailsjs/trailpack-hapi#3

weyj4 commented 8 years ago

This is specifically what I'm trying to implement: https://github.com/hapijs/inert#static-file-server

It seems to me that we'd want this to go in config/{something}. But any handler in config/ gets split with the expectation that it's of the form Controller.HandlerFunction inside api/controllers. I just want to pass an object directly into config for this.

weyj4 commented 8 years ago

@lynnaloo @ryanwilliamquinn do either of y'all have input? Linda and I talked about this some this morning.

lynnaloo commented 8 years ago

By the spec, Hapi handlers can be both an object or a function. Serving a static directory is just one example of that so it doesn't seem right to decorate the handlers before adding the route.

In the Hapi source code, I believe that if the handler is an object, then it gets decorated to look like the typical function format. If the router can't accept an object, then maybe the solution is to add a similar decorator here?

weyj4 commented 8 years ago

@tjwebb we can close this if you want. at any rate it's mostly hapi-specific.

jaumard commented 8 years ago

Now it's fix we also allow object, I'm closing this :)