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

feat(server): shared data between requests and plugins for Response #280

Merged
merged 4 commits into from
Sep 10, 2015

Conversation

Ryman
Copy link
Member

@Ryman Ryman commented Sep 9, 2015

I've ripped out the core from #272 and decided we should just push separate crates for now until the implementation for Session/Cookies has settled. This allows more breaking changes to the session/cookies implementations as we experiment without requiring a load of version bumps to nickel itself. It's more work for us to manage, but should be better for users 👍

I've also added a default type for the typeparam, so breakage in client crates should be minimal (until they start using the dataparam!) and only really affect people who've written library level stuff.

r? @cburgdorf @simonpersson

This can be used to add some compile time dependencies for
Middleware and Plugins.

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
There is a default for the type-param to help mitigate breakage,
but some code will probably still be significantly broken by this.

To fix code broken by this, you will need to introduce a type
parameter for various nickel types including: Request, Response,
Middleware, MiddlewareResult and NickelError.

```
// e.g. This:
fn foo<'mw>(&mut Request, Response<'mw>) -> MiddlewareResult<'mw>

// Should become:
fn foo<'mw, D>(&mut Request<D>, Response<'mw, D>) -> MiddlewareResult<'mw, D>

// Or you can use a concrete type:
fn foo<'mw>(&mut Request<MyType>, Response<'mw, MyType>) -> MiddlewareResult<'mw, MyType>
```
Also adds `on_send` which can be used to execute code
when the Response headers are being sent.
@Ryman
Copy link
Member Author

Ryman commented Sep 9, 2015

Pushed cookies to https://github.com/nickel-org/cookies

Will push session later after I've cherry-picked from old branch, have to head out for a bit first!

@cburgdorf
Copy link
Member

👍 awesome. Can't wait for it to land :)

@Ryman
Copy link
Member Author

Ryman commented Sep 9, 2015

Can't wait for it to land :)

== r+ ? 🙈 (Let homu know if so!)

@cburgdorf
Copy link
Member

Let's do it :)

@homu r+

@homu
Copy link
Contributor

homu commented Sep 10, 2015

📌 Commit fc35544 has been approved by cburgdorf

@homu
Copy link
Contributor

homu commented Sep 10, 2015

⌛ Testing commit fc35544 with merge dabfce8...

homu added a commit that referenced this pull request Sep 10, 2015
feat(server): shared data between requests and plugins for Response

I've ripped out the core from #272 and decided we should just push separate crates for now until the implementation for Session/Cookies has settled. This allows more breaking changes to the session/cookies implementations as we experiment without requiring a load of version bumps to nickel itself. It's more work for us to manage, but should be better for users 👍 

I've also added a default type for the typeparam, so breakage in client crates should be minimal (until they start using the dataparam!) and only really affect people who've written library level stuff.

r? @cburgdorf @simonpersson
@homu
Copy link
Contributor

homu commented Sep 10, 2015

☀️ Test successful - status

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

Successfully merging this pull request may close these issues.

3 participants