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

Handling Sessions with an 'Environment' #246

Closed
wants to merge 13 commits into from

Commits on Aug 1, 2015

  1. feat(server): add some shared data across all requests

    This can be used to add some compile time dependencies for
    Middleware and Plugins.
    
    To fix code broken by this, you will need to introduce a type
    parameter for Request, Response, MiddlewareResult and NickelError.
    
    ```
    // e.g. This
    fn foo<'a>(&mut Request, Response<'a>) -> MiddlewareResult<'a>
    
    // Should become:
    fn foo<'a, D>(&mut Request<D>, Response<'a, D>) -> MiddlewareResult<'a, D>
    ```
    
    You can add bounds to `D` in the above to place compile-time restrictions on
    the server data (can be used for configuration).
    
    BREAKING CHANGE
    Ryman committed Aug 1, 2015
    Configuration menu
    Copy the full SHA
    d8983be View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    47b0136 View commit details
    Browse the repository at this point in the history
  3. feat(response): allow Plugins for Response

    Also adds `on_send` which can be used to execute code
    when the Response headers are being sent.
    Ryman committed Aug 1, 2015
    Configuration menu
    Copy the full SHA
    2304e8c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    1239748 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    13f1ad4 View commit details
    Browse the repository at this point in the history
  6. fix(cookies): add explicit implementations for Cookies trait

    The 1.2 beta has a regression for this kind of code, so being
    explicit should allow us to compile on all targets.
    Ryman committed Aug 1, 2015
    Configuration menu
    Copy the full SHA
    7a60286 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    5b4e23b View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    23bb400 View commit details
    Browse the repository at this point in the history
  9. refactor(*): Request is now accessible through a Response instance

    This is motivated to allow writing Plugins which are able to access
    both the current Response and Request without having to rely on odd
    syntax such as `(foo, bar).baz()`.
    
    BREAKING CHANGE: This breaks a *lot* of nickel usage, checking the diff
    from the examples should help to migrate code relying on the old structure.
    Ryman committed Aug 1, 2015
    Configuration menu
    Copy the full SHA
    ebc6aa9 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    47a728d View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    4fb224d View commit details
    Browse the repository at this point in the history
  12. feat(macros): allow hinting the server data type in middleware macro

    This can sometimes be required when using some middleware which are
    predicated on the datatype of the Server. An alternative would be to
    litter the handler with extra type annotations (which is awkward without
    type ascription), or to use explicit type-annotated functions as middleware.
    
    Example usage:
    ```
    middleware! { |res| <ServerData>
       // res is of type Response<ServerData>
    }
    ```
    Ryman committed Aug 1, 2015
    Configuration menu
    Copy the full SHA
    edea3ab View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    5aa0833 View commit details
    Browse the repository at this point in the history