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

Simplify middleware used in tests to parse the body #459

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cibernox
Copy link
Contributor

In preparation of the docs, I've simplified it so it's more idiomatic.

@cibernox cibernox force-pushed the simplify-post-middleware-used-in-testing branch from 5c63e9a to f906581 Compare July 28, 2017 19:31
} else {
next();
}
fastbootMiddleware(req, resp, next);
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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.
@cibernox cibernox force-pushed the simplify-post-middleware-used-in-testing branch from f906581 to d3e144b Compare July 31, 2017 12:20
@kratiahuja
Copy link
Contributor

@cibernox do you want me to wait on this PR or release?

@cibernox
Copy link
Contributor Author

Release if you can. This is just a simplification on the tests. Purely for my own satisfaction.

@kratiahuja
Copy link
Contributor

@cibernox 1.0.2 is released.

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.

None yet

2 participants