Skip to content

feature(hyper): <insert *fireworks* here> #157

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

Merged
merged 29 commits into from
Mar 4, 2015

Conversation

Ryman
Copy link
Member

@Ryman Ryman commented Feb 27, 2015

This is basically feature parity with master, there's still a decent amount I'd like to change/introduce, but I feel this is in a state where it should be reasonably stable enough for review and can allow us to iterate together.

This obviously breaks a lot of code, and I'm especially unsure about the error handling. I've chosen to only allow error handlers to operate on a response that is already in progress (I still think NickelError needs a redesign but didn't want to sneak an opinionated rewrite into this). The reasoning is that either the handler knows what the error is (BadRequest, etc) and can give appropriate status and kick off the request or the error happens mid-stream and it would be a logic error to have an error handler try to edit the StatusCode mid-response. The stream is optional in NickelError as there could be a write error, and then writing on the stream is useless, and the handlers point is just to log.

Most blanket impls for Middleware are removed so that we only have one blanket impl (which will be a requirement for unboxed closures). I actually left in two since one is equivalent to an unboxed closure with ref captures which can be removed in future.

I added convenience macros middleware! to provide similar syntax as an unboxed closure as there are still tricky lifetime issues that need to be dealt with to get them working (I gave it a number of frustrating attempts before moving on with a more flexible macro based approach). I think it might actually be worth adding an error_handler! variant and splitting the current macro into middleware! and handler!, the former returning MiddlewareResult, the latter T: ResponseFinalizer.

Documentation has only really been updated to pass tests, a lot of it could benefit from a rewrite, I don't feel it's a blocking issue.

Bare in mind this has been through a number of rebases, so please point out nits where I've botched something! Also open to naming bikeshedding for anything introduced here. I'll probably do some additional cleanup in the next day or two.

cc @simonpersson @cburgdorf @rgs1

This will fail travis until typemap & plugin merge upstream PRs.

Closes #99.

Ryman added 27 commits February 27, 2015 17:29
Code of the form below will break, with no simple workaround:
fn handler(..) {
  ..
  (status_code, str, vec![header, header, header])
}

[breaking-change]
This will break any code trying to perform undefined behaviour as
mentioned in nickel-org#99. Anything that performed multiple sends, or
modified headers after sending data will be affected by this.
(Although that pretty much breaks HTTP anyway)

[breaking-change]

Closes nickel-org#99.
This will be necessary for an eventual move to unboxed closures.

The majority of current Middleware that used the blanket impls
should probably be valid if wrapped in a middleware! macro instead.

Obviously a huge [breaking-change]
@SimonTeixidor
Copy link
Member

Cool! It wasn't as big of a change as I anticipated really, no huge architectural changes, so that's nice.

I left a few comments but it looks nice overall. Super exciting news this! Thanks for the great work @Ryman!

@rgs1
Copy link
Contributor

rgs1 commented Mar 2, 2015

generally lgtm! having this merged sooner rather than later (even with some rough edges) would be nice so that catching up with Hyper is simpler and so that we can start using it. thanks @Ryman !

@Ryman
Copy link
Member Author

Ryman commented Mar 2, 2015

Lots of upstream change to new io on todays nightly so rust-http is now completely broken :(

I tried to fix it up but each fix just leads to more compiler errors as it unveils more typechecking issues etc. Hyper's broken too but they have a patch already done that just needs to land, which then probably needs adjustment on this branch to accommodate but then we're good?

@rgs1
Copy link
Contributor

rgs1 commented Mar 2, 2015

yeah if we merge this, we can then all pitch in for polishing the rough edges and keeping up to date with hyper.

@ninjabear
Copy link
Contributor

@rgs1 - seconded

also @Ryman, nice one!

@steveklabnik
Copy link

This would be neat becuase currently, nickel fails to build due to rust-http

@Ryman
Copy link
Member Author

Ryman commented Mar 4, 2015

@simonpersson Pushed the io fixes and I think your comments are addressed? Looks like the latest nightly (even though I downloaded mine like 2hours ago..) is broken for some upstream stuff though so Travis is still going to fail ( rust-lang/regex#51 )

@SimonTeixidor
Copy link
Member

Looks nice to me!

@rgs1
Copy link
Contributor

rgs1 commented Mar 4, 2015

w00t! are we ready to rock/merge? :-)

@Ryman
Copy link
Member Author

Ryman commented Mar 4, 2015

@simonpersson upstream's fixed, travis passing, merging!

Ryman added a commit that referenced this pull request Mar 4, 2015
feature(hyper): migrate from rust-http to hyper
@Ryman Ryman merged commit fb71d23 into nickel-org:master Mar 4, 2015
@SimonTeixidor
Copy link
Member

Yay! Great work @Ryman!

@rgs1
Copy link
Contributor

rgs1 commented Mar 5, 2015

awesome - thanks @Ryman !

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.

Response#send should handle state
5 participants