Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: abakas/rails-api
base: master
...
head fork: wintery/rails-api
compare: master
  • 18 commits
  • 4 files changed
  • 0 commit comments
  • 8 contributors
Commits on Apr 23, 2012
Juan E. Pemberthy jpemberthy Why would we need `jquery-rails` in the plugin? 1b673f8
Commits on Apr 24, 2012
Carlos Antonio da Silva carlosantoniodasilva Merge pull request #9 from jpemberthy/patch-1
Remove `jquery-rails` from Gemfile
d0a7831
Carlos Antonio da Silva carlosantoniodasilva Merge pull request #7 from abakas/master
Remove additional asset artifacts from generated app
9760231
Eduardo Cobuci educobuci added compatibility to 'helper_method' eceb531
Carlos Antonio da Silva carlosantoniodasilva Merge pull request #10 from educobuci/helper_method_compatibility
Added compatibility to 'helper_method'. Closes #6
0ceb574
Commits on Apr 26, 2012
Philip Misiowiec philm ensures correct SSL module is used
ActionDispatch::SSL in not part of
https://github.com/rails/rails/tree/3-2-stable/actionpack/lib/action_dis
patch/middleware and was added later.
6b0904b
Commits on Apr 27, 2012
Julio Monteiro jmonteiro Explaninig what is ActionDispatch::RequestId and Rails::Rack::Logger …
…in the README
23756c6
Julio Monteiro jmonteiro Alphabetical ordering middlewares in README 3678409
Julio Monteiro jmonteiro "API", not "api" ef41c4b
Carlos Antonio da Silva carlosantoniodasilva Merge pull request #13 from jmonteiro/minor-readme-improvement
Minor README improvement
55f27d2
Commits on May 02, 2012
Santiago Pastorino spastorino Merge pull request #12 from webficient/master
Fixed issue related to force_ssl = true when using Rails 3.2.3
b741329
Santiago Pastorino spastorino Add Travis CI config 5a645c3
Santiago Pastorino spastorino Add build status to the README c92d3d2
Commits on May 03, 2012
jtmkrueger jtmkrueger Update README.md adding ::ControllerMethods to the ActionController::…
…HtthAuthentication:: remark
c469ac4
Carlos Antonio da Silva carlosantoniodasilva Merge pull request #15 from jtmkrueger/patch-1
Fix README [ci skip]
77d8447
Commits on May 04, 2012
Carlos Antonio da Silva carlosantoniodasilva Fix readme markup [ci skip] da5862d
Commits on May 14, 2012
Winter wintery Added Devise helper method stub to Compatibility fb1d9fc
Carlos Antonio da Silva carlosantoniodasilva Merge pull request #22 from wintery/devise_helper_stub
Added Devise helper method stub to Compatibility
ff406ad
4 .travis.yml
View
@@ -0,0 +1,4 @@
+rvm:
+ - 1.9.3
+notifications:
+ email: false
31 README.md
View
@@ -1,5 +1,7 @@
# Rails::API
+[![Build Status](https://secure.travis-ci.org/spastorino/rails-api.png?branch=master)](http://travis-ci.org/spastorino/rails-api)
+
**Rails::API** is a subset of a normal Rails application, created for applications that don't require all functionality that a complete Rails application provides. It is a bit more lightweight, and consequently a bit faster than a normal Rails application. The main example for its usage is in API applications only, where you usually don't need the entire Rails middleware stack nor template generation.
## Using Rails for API-only Apps
@@ -107,22 +109,22 @@ And comment out the `protect_from_forgery` call if you are using it.
### Choosing Middlewares
-An api application comes with the following middlewares by default.
+An API application comes with the following middlewares by default.
-* *Rack::Cache*: Caches responses with public *Cache-Control* headers using HTTP caching semantics.
-* *Rack::Sendfile*: Uses a front-end server's file serving support from your Rails application.
-* *Rack::Lock*: If your application is not marked as threadsafe (`config.threadsafe!`), this middleware will add a mutex around your requests.
-* *ActionDispatch::RequestId*
-* *Rails::Rack::Logger*
-* *Rack::Runtime*: Adds a header to the response listing the total runtime of the request.
-* *ActionDispatch::ShowExceptions*: Rescue exceptions and re-dispatch them to an exception handling application.
* *ActionDispatch::DebugExceptions*: Log exceptions.
-* *ActionDispatch::RemoteIp*: Protect against IP spoofing attacks.
-* *ActionDispatch::Reloader*: In development mode, support code reloading.
-* *ActionDispatch::ParamsParser*: Parse XML, YAML and JSON parameters when the request's *Content-Type* is one of those.
* *ActionDispatch::Head*: Dispatch *HEAD* requests as *GET* requests, and return only the status code and headers.
+* *ActionDispatch::ParamsParser*: Parse XML, YAML and JSON parameters when the request's *Content-Type* is one of those.
+* *ActionDispatch::Reloader*: In development mode, support code reloading.
+* *ActionDispatch::RemoteIp*: Protect against IP spoofing attacks.
+* *ActionDispatch::RequestId*: Makes a unique request id available, sending the id to the client via the X-Request-Id header. The unique request id can be used to trace a request end-to-end and would typically end up being part of log files from multiple pieces of the stack.
+* *ActionDispatch::ShowExceptions*: Rescue exceptions and re-dispatch them to an exception handling application.
+* *Rack::Cache*: Caches responses with public *Cache-Control* headers using HTTP caching semantics.
* *Rack::ConditionalGet*: Supports the `stale?` feature in Rails controllers.
* *Rack::ETag*: Automatically set an *ETag* on all string responses. This means that if the same response is returned from a controller for the same URL, the server will return a *304 Not Modified*, even if no additional caching steps are taken. This is primarily a client-side optimization; it reduces bandwidth costs but not server processing time.
+* *Rack::Lock*: If your application is not marked as threadsafe (`config.threadsafe!`), this middleware will add a mutex around your requests.
+* *Rack::Runtime*: Adds a header to the response listing the total runtime of the request.
+* *Rack::Sendfile*: Uses a front-end server's file serving support from your Rails application.
+* *Rails::Rack::Logger*: Log the request started and flush all loggers after it.
Other plugins, including *ActiveRecord*, may add additional middlewares. In general, these middlewares are agnostic to the type of app you are building, and make sense in an API-only Rails application.
@@ -148,7 +150,7 @@ config.middleware.use Rack::MethodOverride
#### Removing Middlewares
-If you don't want to use a middleware that is included by default in the api middleware set, you can remove it using *config.middleware.delete*:
+If you don't want to use a middleware that is included by default in the API middleware set, you can remove it using *config.middleware.delete*:
```ruby
config.middleware.delete ::Rack::Sendfile
@@ -158,7 +160,7 @@ Keep in mind that removing these features may remove support for certain feature
### Choosing Controller Modules
-An api application (using *ActionController::API*) comes with the following controller modules by default:
+An API application (using *ActionController::API*) comes with the following controller modules by default:
* *ActionController::UrlFor*: Makes *url_for* and friends available
* *ActionController::Redirecting*: Support for *redirect_to*
@@ -185,14 +187,13 @@ All Action Controller modules know about their dependent modules, so you can fee
Some common modules you might want to add:
* *AbstractController::Translation*: Support for the *l* and *t* localization and translation methods. These delegate to *I18n.translate* and *I18n.localize*.
-* *ActionController::HttpAuthentication::Basic* (or *Digest* or *Token*): Support for basic, digest or token HTTP authentication.
+* *ActionController::HttpAuthentication::Basic::ControllerMethods* (or *Digest* or *Token*): Support for basic, digest or token HTTP authentication.
* *AbstractController::Layouts*: Support for layouts when rendering.
* *ActionController::MimeResponds*: Support for content negotiation (*respond_to*, *respond_with*).
* *ActionController::Cookies*: Support for *cookies*, which includes support for signed and encrypted cookies. This requires the cookie middleware.
The best place to add a module is in your *ApplicationController*. You can also add modules to individual controllers.
-
## Contributing
1. Fork it
2  lib/rails-api/action_controller/api.rb
View
@@ -98,6 +98,8 @@ def perform_caching=(*); end
def wrap_parameters(*); end
def helpers_path=(*); end
def allow_forgery_protection=(*); end
+ def helper_method(*); end
+ def helper(*); end
end
extend Compabitility
11 lib/rails-api/application.rb
View
@@ -11,7 +11,7 @@ def default_middleware_stack
end
if config.force_ssl
- middleware.use ::ActionDispatch::SSL, config.ssl_options
+ middleware.use ssl_module, config.ssl_options
end
if config.action_dispatch.x_sendfile_header.present?
@@ -64,6 +64,15 @@ def add_resource_route
private
+ def ssl_module
+ if defined? ::ActionDispatch::SSL
+ ::ActionDispatch::SSL
+ else
+ require 'rack/ssl'
+ ::Rack::SSL
+ end
+ end
+
def setup_generators!
generators = config.generators

No commit comments for this range

Something went wrong with that request. Please try again.