Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctx.data in routes and helpers (0.3.0) #91

Open
shimaore opened this issue Sep 30, 2011 · 0 comments
Open

ctx.data in routes and helpers (0.3.0) #91

shimaore opened this issue Sep 30, 2011 · 0 comments

Comments

@shimaore
Copy link
Contributor

Idea: let's use ctx.data to represent the databag inside routes and helpers. This is especially convenient in helpers where values might come from req.query or req.body (when using bodyDecoder) depending on the calling environment (get vs post). In routes @data would allow for pre-0.3-like semantics (= more direct migration strategy).

Suggested changes:
line 265

      if app.settings['databag']
        args[1].params = ctx.data

line 287

    if app.settings['databag']
      ctx.data = {}
      copy_data_to ctx.data, [req.query, req.params, req.body]

line 292

    switch app.settings['databag']
      when 'this' then result = r.handler.apply(ctx.data, [ctx])
      when 'param' then result = r.handler.apply(ctx, [ctx.data])
      else result = r.handler.apply(ctx, [ctx])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant