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.

...
  • 3 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
30 README.md
View
@@ -322,6 +322,7 @@ It offers convenient access to cookies.
They are read as an Hash from Rack env:
```ruby
+require 'lotus/controller'
require 'lotus/action/cookies'
class ReadCookiesFromRackEnv
@@ -341,6 +342,7 @@ action.call({'HTTP_COOKIE' => 'foo=bar'})
They are set like an Hash:
```ruby
+require 'lotus/controller'
require 'lotus/action/cookies'
class SetCookies
@@ -360,6 +362,7 @@ action.call({}) # => [200, {'Set-Cookie' => 'foo=bar'}, '...']
They are removed by setting their value to `nil`:
```ruby
+require 'lotus/controller'
require 'lotus/action/cookies'
class RemoveCookies
@@ -381,6 +384,7 @@ action.call({}) # => [200, {'Set-Cookie' => "foo=; max-age=0; expires=Thu, 01 Ja
It has builtin support for Rack sessions:
```ruby
+require 'lotus/controller'
require 'lotus/action/session'
class ReadSessionFromRackEnv
@@ -400,6 +404,7 @@ action.call({ 'rack.session' => { 'age' => '31' }})
Values can be set like an Hash:
```ruby
+require 'lotus/controller'
require 'lotus/action/session'
class SetSession
@@ -419,6 +424,7 @@ action.call({}) # => [200, {"Set-Cookie"=>"rack.session=..."}, "..."]
Values can be removed like an Hash:
```ruby
+require 'lotus/controller'
require 'lotus/action/session'
class RemoveSession
@@ -603,6 +609,30 @@ loading your controllers before you initialize the router.**
Lotus::Controller is compatible with Rack. However, it doesn't mount any middleware.
While a Lotus application's architecture is more web oriented, this framework is designed to build pure HTTP entpoints.
+## Thread safety
+
+An Action is **mutable**. When used without Lotus::Router, be sure to instantiate an
+action for each request.
+
+```ruby
+# config.ru
+require 'lotus/controller'
+
+class Action
+ include Lotus::Action
+
+ def self.call(env)
+ new.call(env)
+ end
+
+ def call(params)
+ self.body = object_id.to_s
+ end
+end
+
+run Action
+```
+
## Versioning
__Lotus::Controller__ uses [Semantic Versioning 2.0.0](http://semver.org)
1  lib/lotus-controller.rb
View
@@ -0,0 +1 @@
+require 'lotus/controller'
6 lib/lotus/action/callable.rb
View
@@ -26,7 +26,7 @@ module Callable
# @since 0.1.0
#
# @example with Lotus::Router
- # require 'lotus/action'
+ # require 'lotus/controller'
#
# class Show
# include Lotus::Action
@@ -38,7 +38,7 @@ module Callable
# end
#
# @example Standalone
- # require 'lotus/action'
+ # require 'lotus/controller'
#
# class Show
# include Lotus::Action
@@ -52,7 +52,7 @@ module Callable
# end
#
# @example Unit Testing
- # require 'lotus/action'
+ # require 'lotus/controller'
#
# class Show
# include Lotus::Action
4 lib/lotus/action/callbacks.rb
View
@@ -44,7 +44,7 @@ def self.extended(base)
# @since 0.1.0
#
# @example Method names (symbols)
- # require 'lotus/action'
+ # require 'lotus/controller'
#
# class Show
# include Lotus::Action
@@ -72,7 +72,7 @@ def self.extended(base)
# # 3. #call
#
# @example Anonymous functions (Procs)
- # require 'lotus/action'
+ # require 'lotus/controller'
#
# class Show
# include Lotus::Action
2  lib/lotus/action/cookies.rb
View
@@ -32,7 +32,7 @@ def finish
# @api public
#
# @example
- # require 'lotus/action'
+ # require 'lotus/controller'
# require 'lotus/action/cookies'
#
# class Show
2  lib/lotus/action/mime.rb
View
@@ -42,7 +42,7 @@ module ClassMethods
# @since 0.1.0
#
# @example
- # require 'lotus/action'
+ # require 'lotus/controller'
#
# class Show
# include Lotus::Action
2  lib/lotus/action/session.rb
View
@@ -20,7 +20,7 @@ module Session
# @since 0.1.0
#
# @example
- # require 'lotus/action'
+ # require 'lotus/controller'
# require 'lotus/action/session'
#
# class Show
2  lib/lotus/action/throwable.rb
View
@@ -58,7 +58,7 @@ def self.extended(base)
# @see Lotus::Action.handled_exceptions
#
# @example
- # require 'lotus/action'
+ # require 'lotus/controller'
#
# class Show
# include Lotus::Action
2  lib/lotus/controller.rb
View
@@ -43,7 +43,7 @@ module Controller
# @see Lotus::Action::Throwable
#
# @example
- # require 'lotus/action'
+ # require 'lotus/controller'
#
# Lotus::Controller.handled_exceptions = { RecordNotFound => 404 }
#

No commit comments for this range

Something went wrong with that request. Please try again.