lamernews
lamernews copied to clipboard
use Rack for API
Extracting the API into a Rack middleware might be interesting to combine Lamernews with other Rack applications, and/or to build a custom UI variation.
Glad to hear your feedback if this is interesting for you.
The Lamernews API would then be accessible from Rack with:
use Lamernews::API
While it could be interesting, this breaks the ability to simply install the few required gems manually and launch Lamer News by simply invoking "ruby app.rb", which makes it really easy even for Ruby neophytes to get involved.
Maybe putting the API code in a separate file (could be "api.rb") and simply requiring it from the "app.rb" file could be a good compromise?
Interesting. I will check.
I think this is a great idea though, and it should probably be explored!
Also, it could makes things easier to create Lamer News implementations in other languages. As far as I know, there is only one port currently, written in Perl : https://github.com/beanz/camelnews
When using middlewares, it might make sense to use a middleware to connect to Redis, since that DB layer will be used both in the UI, and in the API part. I updated the PR, it's very experiment. However, both work:
ruby app.rb rackup
hope @antirez will merge this pull request soon. I want to have a clean way to integrate lamernews to my rails app
Actually, I guess the PR is rather to be closed, since Lamernews and Rails are a bit off different architectures. I would be interested though to hear if this works in principle. I also saw that @mitchellh supports Rack based application architectures: https://github.com/euruko2012/call-for-proposals/pull/83
On Wed, Sep 18, 2013 at 5:41 PM, huydx [email protected] wrote:
hope @antirez https://github.com/antirez will merge this pull request soon. I want to have a clean way to integrate lamernews to my rails app
— Reply to this email directly or view it on GitHubhttps://github.com/antirez/lamernews/pull/142#issuecomment-24674757 .
@mulderp Vagrant is completely based on "Rack-style" middleware, see here: https://github.com/mitchellh/vagrant/blob/master/plugins/providers/virtualbox/action.rb#L52-L78
great! thanks for the pointer!
On Wed, Sep 18, 2013 at 6:11 PM, Mitchell Hashimoto < [email protected]> wrote:
@mulderp https://github.com/mulderp Vagrant is completely based on "Rack-style" middleware, see here: https://github.com/mitchellh/vagrant/blob/master/plugins/providers/virtualbox/action.rb#L52-L78
— Reply to this email directly or view it on GitHubhttps://github.com/antirez/lamernews/pull/142#issuecomment-24677378 .