Looking for rack app structure and config.ru specs?
Asked Answered
G

2

13

This will probably make me look lame but still -- I can't find any formal description for either a typical rack application structure (folders/files, like public, config.ru), or the config.ru file contents.

In the Java world there's a clear definition of a web application and the parts it comprised of (WEB-INF, META-INF web.xml).

Is there a specification of a Rack web application at all? Or is it something vague like Ruby itself.

I expected to find that info somewhere on the http://rack.rubyforge.org/ site but I couldn't. Please point me in the right direction.


Although I marked this question as answered it is worth mentioning that the question itself in not very legitimate. The app structure is driven by the actual webserver/plugin combination in use, like Apache/Passenger, and not Rack.

Gamble answered 29/11, 2011 at 14:56 Comment(2)
Did you see rack.rubyforge.org/doc/SPEC.html ? Also, the config.ru contents are evaluated in the context of Rack::Builder.Braggart
it did seem more like an API walkthrough, rather than description of a rack web app layout, will take a look againGamble
O
2

A Rack web application is as simple as:

class HelloWorld
  def call(env)
    [200, {"Content-Type" => "text/plain"}, ["Hello world!"]]
  end
end

and as complex as apps built on frameworks like Rails, Sinatra, and so on, built on Rack.

Pertaining to structure, you can create yours. With Rack, you generate content the way you want it to be structured. With Rack, you are basically outputting raw HTTP content.

"Introducing Rack", "32 Rack Resources to Get You Started" and "Introduction to Rack middleware" are resources to understand Rack better.

Pertaining to structure, you have freedom in organizing files to suite the webapp. You may have other Rack applications in different files; All you need is to properly require those files.

A Rack app can be any Ruby class that responds to the :call message with env, just like the HelloWorld app above.

Overzealous answered 29/11, 2011 at 16:0 Comment(2)
if we talk in Java terms can we say that Rack defines just the Servlet API, and not the layout (directory structure) of a web application? i.e. there is no such thing as a definition of where config.ru must be placed relative to the web app classes (rb files)?Gamble
there is no specification per se. but the config.ru is sorta what fires up the app. it would be ideal if this is in the home (or root) directory of your web appOverzealous
E
1

Have you checked the Rack Wiki? It contains a bunch of various links to tutorials, presentations etc. (But I'm not sure about specs.)

Exhalant answered 29/11, 2011 at 15:30 Comment(1)
hmm I've been there but missed the @rackup@ How-To somehow, it could be what I need for the config.ru spec part...Gamble

© 2022 - 2024 — McMap. All rights reserved.