Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 20 commits
  • 7 files changed
  • 0 commit comments
  • 9 contributors
Commits on Apr 22, 2012
@dpowell dpowell Don't include jquery-rails in Gemfile 8379f97
@dpowell dpowell Don't generate asset directories in tmp or vendor 4a2a8af
Commits on Apr 23, 2012
@jpemberthy Why would we need `jquery-rails` in the plugin? 1b673f8
Commits on Apr 24, 2012
@carlosantoniodasilva carlosantoniodasilva Merge pull request #9 from jpemberthy/patch-1
Remove `jquery-rails` from Gemfile
d0a7831
@carlosantoniodasilva carlosantoniodasilva Merge pull request #7 from abakas/master
Remove additional asset artifacts from generated app
9760231
@educobuci educobuci added compatibility to 'helper_method' eceb531
@carlosantoniodasilva carlosantoniodasilva Merge pull request #10 from educobuci/helper_method_compatibility
Added compatibility to 'helper_method'. Closes #6
0ceb574
Commits on Apr 26, 2012
@philm 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
@jmonteiro jmonteiro Explaninig what is ActionDispatch::RequestId and Rails::Rack::Logger …
…in the README
23756c6
@jmonteiro jmonteiro Alphabetical ordering middlewares in README 3678409
@jmonteiro jmonteiro "API", not "api" ef41c4b
@carlosantoniodasilva carlosantoniodasilva Merge pull request #13 from jmonteiro/minor-readme-improvement
Minor README improvement
55f27d2
Commits on May 02, 2012
@spastorino spastorino Merge pull request #12 from webficient/master
Fixed issue related to force_ssl = true when using Rails 3.2.3
b741329
@spastorino spastorino Add Travis CI config 5a645c3
@spastorino 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
@carlosantoniodasilva carlosantoniodasilva Merge pull request #15 from jtmkrueger/patch-1
Fix README [ci skip]
77d8447
Commits on May 04, 2012
@carlosantoniodasilva carlosantoniodasilva Fix readme markup [ci skip] da5862d
Commits on May 14, 2012
@wintery wintery Added Devise helper method stub to Compatibility fb1d9fc
@carlosantoniodasilva carlosantoniodasilva Merge pull request #22 from wintery/devise_helper_stub
Added Devise helper method stub to Compatibility
ff406ad
View
4 .travis.yml
@@ -0,0 +1,4 @@
+rvm:
+ - 1.9.3
+notifications:
+ email: false
View
31 README.md
@@ -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
View
2 lib/rails-api/action_controller/api.rb
@@ -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
View
11 lib/rails-api/application.rb
@@ -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
View
5 lib/rails-api/generators/rails/app/app_generator.rb
@@ -4,3 +4,8 @@
Rails::Generators::AppGenerator.source_paths.unshift(
File.expand_path('../../../../templates/rails/app', __FILE__)
)
+
+class Rails::AppBuilder
+ undef tmp
+ undef vendor
+end
View
2 lib/rails-api/templates/rails/app/Gemfile
@@ -9,8 +9,6 @@ gem 'rails-api'
<%= "gem 'jruby-openssl'\n" if defined?(JRUBY_VERSION) -%>
<%= "gem 'json'\n" if RUBY_VERSION < "1.9.2" -%>
-<%= javascript_gemfile_entry %>
-
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
View
11 test/generators/app_generator_test.rb
@@ -10,6 +10,7 @@ def test_skeleton_is_created
run_generator
default_files.each { |path| assert_file path }
+ skipped_files.each { |path| assert_no_file path }
end
def test_api_modified_files
@@ -18,6 +19,7 @@ def test_api_modified_files
assert_file "Gemfile" do |content|
assert_match(/gem 'rails-api'/, content)
assert_no_match(/gem 'coffee-rails'/, content)
+ assert_no_match(/gem 'jquery-rails'/, content)
assert_no_match(/gem 'sass-rails'/, content)
end
assert_file "app/controllers/application_controller.rb", /ActionController::API/
@@ -47,10 +49,11 @@ def default_files
test/functional
test/integration
test/performance
- test/unit
- vendor
- vendor/assets
- tmp/cache
+ test/unit)
+ end
+
+ def skipped_files
+ %w(vendor/assets
tmp/cache/assets)
end
end

No commit comments for this range

Something went wrong with that request. Please try again.