Comments (3)
@baob Hey thanks for reporting this. Are you using lotus-controller
as standalone component or inside a Lotus app?
Actions are mutable, in order to make your application safe you must use a new instance for each request. This is handled for you by lotusrb
, but not if you use lotus-controller
alone.
Please let me know.
from controller.
We are using the two gems (Controller and Router) standalone, we are not using the full lotus app. Can you point me in the right direction please ? I read something yesterday about mutable actions, but what I read suggested that Router would create a new instance every time, so I thought it would not apply to our situation.
This is our routing code:
Lotus::Router.new do
get '/subjects/:subject_slug', to: Actions::SubjectsShow
end
Is it just a case of adding .new
to the class referenced ? Or is there another prefered way to do it ? E.g. I've seen references to using Lotus::Controller.load!
but I have no idea where to place that code.
from controller.
You have two solutions:
- You can add a class method for each action
.call
and do:
def self.call(env)
new.call(env)
end
See more at: https://github.com/lotus/controller#thread-safety
- Or you can on action naming syntax (
to: 'actions#subjects_show
)
from controller.
Related Issues (20)
- Remove body cleanup for HTTP responses that doesn't require a body (e.g. 204) HOT 1
- Flash #empty? returns true when it's not (after a re-direct) HOT 2
- Hanami::Action::Flash to use swappable JSON backend HOT 2
- Flash message appears twice (redux) HOT 3
- Exception Handling in Production HOT 19
- RuntimeError: can't add a new key into hash during iteration HOT 8
- Compatability issue with hanami-controller 2.0.0.alpha1 HOT 2
- Is `#request` supposed to be memoized for actions? HOT 2
- Standalone actions prevent using non-keyword parameters in `#initialize` (v2) HOT 3
- [2.0.0.alpha1] Uninitialized constant Hanami::Controller::Configuration (NameError) HOT 2
- Handling `config` and other class-level macros HOT 3
- accept syntax in README no longer seems supported HOT 1
- Action params are not coerced? HOT 5
- Badly encoded cookie strings from Safari results in an error HOT 3
- HTTP status 418 is missing HOT 1
- Issue with multipart/form-data format HOT 1
- Support CSRF by HTTP header HOT 4
- Support for hanami-validations/dry-validations `rule(...)`
- Documentation about Controller/Router integration is incorrect HOT 7
- Fix Response#send_file implementation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from controller.