Conversation started Apr 11, 2014 at 21:35.
user895378
Apr 11, 2014 21:35
And it's more explicitly readable than seeing some orphan boolean parameter on the end.
or just use constants?
user895378
Hmm ... maybe
that'd allow if necessary some bitmasks
user895378
App::addRoute('/some-uri', FAST_CGI | DOCROOT)
user895378
^ Dispatch to the Fast CGI server and if it returns 404 dispatch to the docroot handler.
Apr 11, 2014 21:37
jup
App::addFastCGIAndDocrootRoute() looks just weird^^
user895378
Yeah I wouldn't do something like that.
and maybe just shorten addRoute() to route()
same for Websockets with bitmask: App::route('/uri', WEBSOCKET)
user895378
What if I have multiple different websocket endpoints?
how you mean?
user895378
/widgets -> WidgetWebsocketClass
/something-else ->SomethingWebsocketClass
user895378
Apr 11, 2014 21:42
There's not just one universal WEBSOCKET handler.
user895378
Wait, yes there is.
user895378
I don't know what I'm talking about.
lol
user895378
But you'd still have to tell the websocket handler which class you're using to handle that URI.
user895378
Because you specify a different class for each individual websocket URI.
Apr 11, 2014 21:44
I was just looking at examples/009_websockets.php
@rdlowrey btw. in the normal routes you also always add some callback, no?
user895378
Yeah, you can add as many separate websocket endpoints as you want ... that example only demonstrates one
user895378
@bwoebi callback?
user895378
$app->addRoute($uri, $handler)
user895378
where the handler is any callable or thing that auryn can provision
yes, this… and in the case of websockets you pass there a class name instead of an handler
user895378
Apr 11, 2014 21:46
Yes.
user895378
It has to be a class name that implements the Aerys\Websocket\App interface
App::route('/uri', 'myClass', WEBSOCKET) that way I meant
user895378
I prefer having separate methods TBH.
user895378
But this interface is really easy to change.
user895378
That's why it exists: to provide a layer of insulation between configuration and the actual code.
Apr 11, 2014 21:47
Well. You have two choices: put everything in one method or everything in its own method. Mixing this is I think a bad idea
user895378
I agree. That's why everything has its own method right now.
@rdlowrey It's just not a long-term solution when you want to set some option etc.
These things still will have some common code I think… redundancy, welcome.
user895378
I've given these things a ton of thought ... it's definitely a long-term solution. I'm not saying it's going to stay exactly how it is now, but there are reasons why it's setup the way it is right now.
user895378
But again, the App configuration interface is the easiest thing to change in the whole code base.
adding more and more methods, just to route?
user895378
Apr 11, 2014 21:50
It's not just for routing.
@rdlowrey E_TOO_MUCH_METHODS_IN_SINGLE_CLASS
user895378
There are lots of configuration options for something like the static file docroot handler, for example.
@rdlowrey and at the same thing a relatively important thing for the user.
user895378
How do you tell the server you want to set Option A, B and C in the docroot handler with your method?
user895378
It's not just for routing.
user895378
Apr 11, 2014 21:51
There are other considerations (such as setting options)
user895378
It just looks like it's for routing because I've made the interfaces easy to understand.
@rdlowrey I said bitmask?
user895378
You'd have a neverending bitmask.
user895378
It's not a good solution.
user895378
And you can't set options for the entire docroot handler on each and every route assignment.
Apr 11, 2014 21:52
Never ending? Why?
@rdlowrey I mean first some general options and then specific option on each route?
user895378
My point is this: there are a ton of other things that have to be accomplished that just don't work using a single route() method with options. And they vary greatly whether they're websocket options or static file handling options, etc.
how do you manage these options currently?
user895378
Take a look at the App class.
user895378
Options relevant to the individual parts go in there. From there the bootstrap process does lots of voodoo to get those settings to the individual handlers.
user895378
Anyway, I'm taking a break for a couple of hours. Feel free to leave any questions you may have and you should have answers when you get back to the computer tomorrow :)
Apr 11, 2014 21:59
Actually, when you have already an options array, you also just can require the first element of it to be the type?
user895378
I prefer more descriptive methods with fewer parameters to fewer methods that have more parameters and do everything.
user895378
It's easier to understand because you don't have to know what a parameter is for.
user895378
The method name tells you.
user895378
Every parameter adds a cognitive cost.
user895378
Anyway, have a good night :)
Apr 11, 2014 22:03
I still can't agree… maybe we should discuss that later on when you'll have too much route methods…
 
Conversation ended Apr 11, 2014 at 22:03.