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
Simplify middleware used in tests to parse the body #459
base: master
Are you sure you want to change the base?
Simplify middleware used in tests to parse the body #459
Conversation
5c63e9a
to
f906581
Compare
} else { | ||
next(); | ||
} | ||
fastbootMiddleware(req, resp, next); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this middleware only be called when it is a POST request and when it is a base page request? if you have tests that request for assets, this would result in an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need to check for the method. POST
, PUT
and PATCH
all can have body. GET
will not, but it doesn't harm to leave it, right?
About the "base page request" what do you mean? That the request has a header requesting for HTML?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GET will not, but it doesn't harm to leave it, right?
yes
About the "base page request" what do you mean? That the request has a header requesting for HTML?
I meant fastboot is serving the index.html page to you with the rendered DOM in it. You only want to send the request to the fastboot-express-middleware if it is a index.html request. You know it is because ember-cli exposes it via req.serveUrl being defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You only want to send the request to the fastboot-express-middleware if it is a index.html
Will that still work if the user is requesting /some/nested/url
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes if you are passing the accept/html request header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kratiahuja I tried but I can't check for req.serverUrl
yet until we fix this line in ember-cli
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll work on a PR to ember-cli itself right now.
In preparation of the docs, I've simplified it so it's more idiomatic.
f906581
to
d3e144b
Compare
@cibernox do you want me to wait on this PR or release? |
Release if you can. This is just a simplification on the tests. Purely for my own satisfaction. |
@cibernox 1.0.2 is released. |
In preparation of the docs, I've simplified it so it's more idiomatic.