Giter VIP home page Giter VIP logo

rack-servlet's Introduction

Rack Servlet Build Status

Embed JRuby Rack applications in your Java container.

Download

In a Maven project, add rack-servlet and jruby-complete to your pom.xml:

<dependencies>
  <dependency>
    <groupId>com.squareup.rack</groupId>
    <artifactId>rack-servlet</artifactId>
    <version>${rack.servlet.version}</version>
  </dependency>
  <dependency>
    <groupId>org.jruby</groupId>
    <artifactId>jruby-complete</artifactId>
    <version>${jruby.version}</version>
  </dependency>
</dependencies>

Quick Start

// Use JRuby to build your Rack application:
ScriptingContainer ruby = new ScriptingContainer();
IRubyObject application = ruby.parse("lambda { |env| [200, {}, ['Hello, World!']] }").run();

// Build a RackServlet with that Rack application:
Servlet servlet = new RackServlet(new JRubyRackApplication(application));

// Install that servlet in your container...
// (See our examples directory for concrete code.)

In Depth

  • Gems: You can use the gem-maven-plugin to put gems in your pom.xml on your test classpath. For production deployments, you'll need to be a little more clever.
  • Frameworks: We're successfully running Sinatra applications on Rack Servlet. We've not yet tried Rails. At any rate, you'll need to make separate arrangements for any database connections you may need.
  • Logging: rack.logger and rack.errors use slf4j, so that you can choose your logging backend. Log messages are written to com.squareup.rack.RackLogger and com.squareup.rack.RackErrors, respectively.

Support

Alternatives

Rack Servlet grew out of our desire to embed Rack applications in Square's Java service container, in order to take advantage of our sophisticated infrastructure.

There are other options in the "run Rack applications on the JVM" space, all of which are shaped somewhat differently:

  • Kirk is a Rack server, like Mongrel or Unicorn.
  • Warbler bundles your Rack application into a WAR file.
  • jruby-rack is close in intent to Rack Servlet. It offers amazing support for instantiating and pooling your Rack application objects, though its custom embedding story is less clear.

rack-servlet's People

Contributors

daicoden avatar jakewharton avatar matthewtodd avatar visnup avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.