Goliath::API mounts and http-router

157 views
Skip to first unread message

Peter Kieltyka

unread,
Feb 7, 2012, 11:05:21 PM2/7/12
to Goliath.io
Hey guys,

I've been looking over the commits since 0.9.4 in master and was just
wondering...

1. Why is using "run" disallowed in Goliath::Rack::Builder? .. this
was useful to pass simple Proc's for endpoints, ie.. map '/
favicon.ico' { run Proc.new {|env| [200, {}, ['']] } }. I know there
is a favicon middleware now, but I don't need a favicon for my API.

2. It's cool that http-router is now part of the core, however, can
you guys provide a simple example as how this would be used? I see
there is now a "router" method on the Goliath::API class..

Peter

Ilya Grigorik

unread,
Feb 8, 2012, 12:25:25 AM2/8/12
to golia...@googlegroups.com
For #1, it was disabled to prevent people from shooting themselves in the foot: https://github.com/postrank-labs/goliath/commit/6cd74b8f4013b7f756e9404fb5f4f8de776b88ac

Am I happy with that solution? Not really, but I don't see any other reliable way to solve this for new users.

Peter Kieltyka

unread,
Feb 8, 2012, 10:11:29 AM2/8/12
to golia...@googlegroups.com
Right, that makes sense. Well one idea would be to offer some syntax sugar via blocks.. as so..

class Router < Goliath::API
get "/favicon.ico", Goliath::API.response do |env|
[200, {}, ""]
end
end

... I don't think thats particularly beautiful, but you get the idea. Perhaps the work you guys are putting into supporting "http_router" will help with this as well and help clean up some of the piping.

Ilya Grigorik

unread,
Feb 8, 2012, 11:44:32 AM2/8/12
to golia...@googlegroups.com
Hmm, yeah in theory that could work. To be honest, the http_router stuff is nice, but it brought in a lot of extra complications which we (or "I" at least), did not anticipate from the beginning. A number of these still need to resolved (for one, there is a performance regression which I'm fairly confident is associated with the router), and I'm almost wondering if it should be decoupled and pulled out.

ig

Peter Kieltyka

unread,
Feb 8, 2012, 11:58:33 AM2/8/12
to golia...@googlegroups.com
If you're noticing performance issues, then I agree its best to decouple it. I love Goliath for its minimalistic approach, where as a developer I have more control over the finer mechanics. I think you guys should decide what is core to the framework and where extensions make sense, and build an adapter interface for things like routing, rendering, etc.

On 2012-02-08, at 11:44 AM, Ilya Grigorik wrote:

Reply all
Reply to author
Forward
0 new messages