Permalink
Browse files

Remove --http.

  • Loading branch information...
1 parent 1efeb07 commit 6db930cb5bbff9ad824590b5844e04768de240b1 @josevalim josevalim committed Mar 14, 2012
Showing with 7 additions and 1,020 deletions.
  1. +0 −2 actionpack/CHANGELOG.md
  2. +0 −1 actionpack/lib/action_controller.rb
  3. +0 −134 actionpack/lib/action_controller/http.rb
  4. +0 −4 actionpack/test/abstract_unit.rb
  5. +0 −19 actionpack/test/controller/http/action_methods_test.rb
  6. +0 −55 actionpack/test/controller/http/conditional_get_test.rb
  7. +0 −27 actionpack/test/controller/http/data_streaming_test.rb
  8. +0 −20 actionpack/test/controller/http/force_ssl_test.rb
  9. +0 −19 actionpack/test/controller/http/redirect_to_test.rb
  10. +0 −37 actionpack/test/controller/http/renderers_test.rb
  11. +0 −20 actionpack/test/controller/http/url_for_test.rb
  12. +0 −271 railties/guides/source/api_app.textile
  13. +0 −20 railties/lib/rails/configuration.rb
  14. +1 −22 railties/lib/rails/generators.rb
  15. +0 −8 railties/lib/rails/generators/rails/app/app_generator.rb
  16. +3 −3 railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt
  17. +0 −9 railties/lib/rails/generators/rails/app/templates/config/application.rb
  18. +0 −1 railties/lib/rails/generators/rails/resource/resource_generator.rb
  19. +1 −2 railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
  20. +0 −60 railties/lib/rails/generators/rails/scaffold_controller/templates/http_controller.rb
  21. +2 −4 railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
  22. +0 −50 railties/lib/rails/generators/test_unit/scaffold/templates/http_functional_test.rb
  23. +0 −28 railties/test/application/generators_test.rb
  24. +0 −27 railties/test/application/initializers/frameworks_test.rb
  25. +0 −30 railties/test/application/middleware_test.rb
  26. +0 −20 railties/test/application/rake_test.rb
  27. +0 −33 railties/test/generators/app_generator_test.rb
  28. +0 −6 railties/test/generators/resource_generator_test.rb
  29. +0 −37 railties/test/generators/scaffold_controller_generator_test.rb
  30. +0 −51 railties/test/generators_test.rb
@@ -1,7 +1,5 @@
## Rails 4.0.0 (unreleased) ##
-* Support API apps http://edgeguides.rubyonrails.org/api_app.html *Santiago Pastorino and Carlos Antonio da Silva*
-
* Add `include_hidden` option to select tag. With `:include_hidden => false` select with `multiple` attribute doesn't generate hidden input with blank value. *Vasiliy Ermolovich*
* Removed default `size` option from the `text_field`, `search_field`, `telephone_field`, `url_field`, `email_field` helpers. *Philip Arndt*
@@ -6,7 +6,6 @@ module ActionController
autoload :Base
autoload :Caching
- autoload :HTTP
autoload :Metal
autoload :Middleware
@@ -1,134 +0,0 @@
-require "action_controller/log_subscriber"
-
-module ActionController
- # HTTP Controller is a lightweight version of <tt>ActionController::Base</tt>,
- # created for applications that don't require all functionality that a complete
- # \Rails controller provides, allowing you to create faster controllers. The
- # main scenario where HTTP Controllers could be used is API only applications.
- #
- # An HTTP Controller is different from a normal controller in the sense that
- # by default it doesn't include a number of features that are usually required
- # by browser access only: layouts and templates rendering, cookies, sessions,
- # flash, assets, and so on. This makes the entire controller stack thinner and
- # faster, suitable for API applications. It doesn't mean you won't have such
- # features if you need them: they're all available for you to include in
- # your application, they're just not part of the default HTTP Controller stack.
- #
- # By default, only the ApplicationController in a \Rails application inherits
- # from <tt>ActionController::HTTP</tt>. All other controllers in turn inherit
- # from ApplicationController.
- #
- # A sample controller could look like this:
- #
- # class PostsController < ApplicationController
- # def index
- # @posts = Post.all
- # render json: @posts
- # end
- # end
- #
- # Request, response and parameters objects all work the exact same way as
- # <tt>ActionController::Base</tt>.
- #
- # == Renders
- #
- # The default HTTP Controller stack includes all renderers, which means you
- # can use <tt>render :json</tt> and brothers freely in your controllers. Keep
- # in mind that templates are not going to be rendered, so you need to ensure
- # your controller is calling either <tt>render</tt> or <tt>redirect</tt> in
- # all actions.
- #
- # def show
- # @post = Post.find(params[:id])
- # render json: @post
- # end
- #
- # == Redirects
- #
- # Redirects are used to move from one action to another. You can use the
- # <tt>redirect</tt> method in your controllers in the same way as
- # <tt>ActionController::Base</tt>. For example:
- #
- # def create
- # redirect_to root_url and return if not_authorized?
- # # do stuff here
- # end
- #
- # == Adding new behavior
- #
- # In some scenarios you may want to add back some functionality provided by
- # <tt>ActionController::Base</tt> that is not present by default in
- # <tt>ActionController::HTTP</tt>, for instance <tt>MimeResponds</tt>. This
- # module gives you the <tt>respond_to</tt> and <tt>respond_with</tt> methods.
- # Adding it is quite simple, you just need to include the module in a specific
- # controller or in <tt>ApplicationController</tt> in case you want it
- # available to your entire app:
- #
- # class ApplicationController < ActionController::HTTP
- # include ActionController::MimeResponds
- # end
- #
- # class PostsController < ApplicationController
- # respond_to :json, :xml
- #
- # def index
- # @posts = Post.all
- # respond_with @posts
- # end
- # end
- #
- # Quite straightforward. Make sure to check <tt>ActionController::Base</tt>
- # available modules if you want to include any other functionality that is
- # not provided by <tt>ActionController::HTTP</tt> out of the box.
- class HTTP < Metal
- abstract!
-
- # Shortcut helper that returns all the ActionController::HTTP modules except the ones passed in the argument:
- #
- # class MetalController
- # ActionController::HTTP.without_modules(:ParamsWrapper, :Streaming).each do |left|
- # include left
- # end
- # end
- #
- # This gives better control over what you want to exclude and makes it easier
- # to create a bare controller class, instead of listing the modules required manually.
- def self.without_modules(*modules)
- modules = modules.map do |m|
- m.is_a?(Symbol) ? ActionController.const_get(m) : m
- end
-
- MODULES - modules
- end
-
- MODULES = [
- HideActions,
- UrlFor,
- Redirecting,
- Rendering,
- Renderers::All,
- ConditionalGet,
- RackDelegation,
-
- ForceSSL,
- DataStreaming,
-
- # Before callbacks should also be executed the earliest as possible, so
- # also include them at the bottom.
- AbstractController::Callbacks,
-
- # Append rescue at the bottom to wrap as much as possible.
- Rescue,
-
- # Add instrumentations hooks at the bottom, to ensure they instrument
- # all the methods properly.
- Instrumentation
- ]
-
- MODULES.each do |mod|
- include mod
- end
-
- ActiveSupport.run_load_hooks(:action_controller, self)
- end
-end
@@ -293,10 +293,6 @@ def self.test_routes(&block)
end
end
- class HTTP
- include SharedTestRoutes.url_helpers
- end
-
class TestCase
include ActionDispatch::TestProcess
@@ -1,19 +0,0 @@
-require 'abstract_unit'
-
-class ActionMethodsHTTPController < ActionController::HTTP
- def one; end
- def two; end
- hide_action :two
-end
-
-class ActionMethodsHTTPTest < ActiveSupport::TestCase
- def setup
- @controller = ActionMethodsHTTPController.new
- end
-
- def test_action_methods
- assert_equal Set.new(%w(one)),
- @controller.class.action_methods,
- "#{@controller.controller_path} should not be empty!"
- end
-end
@@ -1,55 +0,0 @@
-require 'abstract_unit'
-
-class ConditionalGetHTTPController < ActionController::HTTP
- before_filter :handle_last_modified_and_etags, :only => :two
-
- def one
- if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag => [:foo, 123])
- render :text => "Hi!"
- end
- end
-
- def two
- render :text => "Hi!"
- end
-
- private
-
- def handle_last_modified_and_etags
- fresh_when(:last_modified => Time.now.utc.beginning_of_day, :etag => [ :foo, 123 ])
- end
-end
-
-class ConditionalGetHTTPTest < ActionController::TestCase
- tests ConditionalGetHTTPController
-
- def setup
- @last_modified = Time.now.utc.beginning_of_day.httpdate
- end
-
- def test_request_with_bang_gets_last_modified
- get :two
- assert_equal @last_modified, @response.headers['Last-Modified']
- assert_response :success
- end
-
- def test_request_with_bang_obeys_last_modified
- @request.if_modified_since = @last_modified
- get :two
- assert_response :not_modified
- end
-
- def test_last_modified_works_with_less_than_too
- @request.if_modified_since = 5.years.ago.httpdate
- get :two
- assert_response :success
- end
-
- def test_request_not_modified
- @request.if_modified_since = @last_modified
- get :one
- assert_equal 304, @response.status.to_i
- assert_blank @response.body
- assert_equal @last_modified, @response.headers['Last-Modified']
- end
-end
@@ -1,27 +0,0 @@
-require 'abstract_unit'
-
-module TestHTTPFileUtils
- def file_name() File.basename(__FILE__) end
- def file_path() File.expand_path(__FILE__) end
- def file_data() @data ||= File.open(file_path, 'rb') { |f| f.read } end
-end
-
-class DataStreamingHTTPController < ActionController::HTTP
- include TestHTTPFileUtils
-
- def one; end
- def two
- send_data(file_data, {})
- end
-end
-
-class DataStreamingHTTPTest < ActionController::TestCase
- include TestHTTPFileUtils
- tests DataStreamingHTTPController
-
- def test_data
- response = process('two')
- assert_kind_of String, response.body
- assert_equal file_data, response.body
- end
-end
@@ -1,20 +0,0 @@
-require 'abstract_unit'
-
-class ForceSSLHTTPController < ActionController::HTTP
- force_ssl
-
- def one; end
- def two
- head :ok
- end
-end
-
-class ForceSSLHTTPTest < ActionController::TestCase
- tests ForceSSLHTTPController
-
- def test_banana_redirects_to_https
- get :two
- assert_response 301
- assert_equal "https://test.host/force_sslhttp/two", redirect_to_url
- end
-end
@@ -1,19 +0,0 @@
-require 'abstract_unit'
-
-class RedirectToHTTPController < ActionController::HTTP
- def one
- redirect_to :action => "two"
- end
-
- def two; end
-end
-
-class RedirectToHTTPTest < ActionController::TestCase
- tests RedirectToHTTPController
-
- def test_redirect_to
- get :one
- assert_response :redirect
- assert_equal "http://test.host/redirect_to_http/two", redirect_to_url
- end
-end
@@ -1,37 +0,0 @@
-require 'abstract_unit'
-
-class Model
- def to_json(options = {})
- { :a => 'b' }.to_json(options)
- end
-
- def to_xml(options = {})
- { :a => 'b' }.to_xml(options)
- end
-end
-
-class RenderersHTTPController < ActionController::HTTP
- def one
- render :json => Model.new
- end
-
- def two
- render :xml => Model.new
- end
-end
-
-class RenderersHTTPTest < ActionController::TestCase
- tests RenderersHTTPController
-
- def test_render_json
- get :one
- assert_response :success
- assert_equal({ :a => 'b' }.to_json, @response.body)
- end
-
- def test_render_xml
- get :two
- assert_response :success
- assert_equal({ :a => 'b' }.to_xml, @response.body)
- end
-end
@@ -1,20 +0,0 @@
-require 'abstract_unit'
-
-class UrlForHTTPController < ActionController::HTTP
- def one; end
- def two; end
-end
-
-class UrlForHTTPTest < ActionController::TestCase
- tests UrlForHTTPController
-
- def setup
- super
- @request.host = 'www.example.com'
- end
-
- def test_url_for
- get :one
- assert_equal "http://www.example.com/url_for_http/one", @controller.url_for
- end
-end
Oops, something went wrong. Retry.

27 comments on commit 6db930c

@jashkenas

Out of curiosity, why is this being removed?

@derekprior

Well, this didn't stick around for long... +1 on the what happened?

@nicolai86

Interesting question. ~4 hours ago @josevalim twittered that rails new --http landed in rails master and now he's removing it already. Care to share the reasons behind that?

@nathanvda

+1 indeed: why is this removed?

@masterkain

wow, some rationale behind this would be nice

@jherdman

+1

@sobrinho

Missing reason yet :P

@ngelx
ngelx commented on 6db930c Mar 15, 2012

+1

@spastorino
Member

Guys let me catch up with some stuff and then I will try to explain the reasons

@deepj
deepj commented on 6db930c Mar 15, 2012

+1

@mcastilho

+1

@raholland79

+1.2

@jeremy
Member
jeremy commented on 6db930c Mar 16, 2012

I have a doubt

@tarcieri

If you were interested in this feature, you should definitely check out Lightrail!

https://github.com/lightness/lightrail

@steveklabnik
Member

This is really disappointing. I was really looking forward to this feature.

@dlitz
dlitz commented on 6db930c Mar 16, 2012

It would be nice if the explanations were included in the commit messages. Just writing "Remove --http." is a bit rude.

@isaacsanders

When I heard this feature would be in, I was excited, and thought that I may use rails like that. Then it gets taken out. I am disappoint.

@coreyhaines

My first opinion is that I'm very happy about this. Let's start cutting things OUT of rails and start moving them into gems that you can bring it. Instead of adding more features into rails, just improve rails so that these features can be added on by gems.

@shapeshed

+1 💀 API ALL THE THINGS

@marceloandrader

I liked this feature, how to put this feature as a gem if the idea was generate the rails app to use as api server.

@tarcieri

In case you missed my earlier remark, Lightrail is this feature (or rather, an earlier version of it) in a separate gem/project which can evolve independently of Rails. Lightrail is a custom Rails 3 stack for JSON APIs, principally authored by @josevalim:

https://github.com/lightness/lightrail

Still untested (working on it!) and early-stage, but please give it a look!

@jeremy
Member
jeremy commented on 6db930c Mar 16, 2012

We're absolutely moving in this direction. This is not one single feature; it's a package of ideas and philosophy wrapped up in a couple config options.

Building up a purpose-built API stack (like we do in our own apps) is the driving force, but that's the benefit, not the feature. So calling it "API" or "HTTP" puts the cart before the horse.

Expect to see these underlying ideas and motivations find their way in to Rails in small, bite-sized pieces: bare applications (bootable engines, you add the middleware), thin controllers (just the http basics, you add serialization, streaming, whatever), and the ability to leave out views/templates entirely.

TL;DR it's coming, but from the ground up instead of from bloat down.

@jherdman

@jeremy good to hear. I'm excited about this change. Anything us outsiders can do to help?

@isaacsanders

@jherdman @jeremy It makes me sad that an OSS project has outsiders. Besides the point.

@fedesoria

Muchas gracias @spastorino

Please sign in to comment.