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

Decouple SwaggerRouter into HttpHandler and Sequence #315

Merged
merged 6 commits into from
Jun 1, 2017

Conversation

bajtos
Copy link
Member

@bajtos bajtos commented May 29, 2017

Building on top of the decoupling work that has already landed, build the first full Sequence object to see where we are. Important: this is not the final implementation, just something that works end-to-end and can serve as a good base for further iterations. The few TODOs left in the code are intentional, they'll allow us to land this patch sooner.

I ended up with a new class HttpHandler which provides a method to handle incoming HTTP request. This method composes RoutingTable, Sequence and bits of custom code to invoke the correct controller method in the correct way. I expect these bits to be moved around as we iterate on the Sequence design and implementation.

The existing Application class wraps HttpHandler and provides sugar API for registering controllers. The Server class is requiring a single Application instance now and passes all requests to this single app.

Connect to #308
See also strongloop-archive/loopback-next-sandbox#1

cc @bajtos @raymondfeng @ritch @superkhau @deepakrkris

Tasks:

  • initial spike
  • fix failing tests
  • clean up type definitions, they are all over the place now
  • define a new API Application.handleHttpRequest(req, res), move most of the request handling code from Server to Application
  • add tests for the newly added code
  • review SwaggerRouter tests and move them to appropriate places
  • remove SwaggerRouter and its tests

@bajtos bajtos self-assigned this May 29, 2017
@bajtos bajtos added the review label May 29, 2017
@bajtos bajtos force-pushed the decompose-router branch 3 times, most recently from 7b948b6 to 3c65e3f Compare June 1, 2017 07:19
@bajtos bajtos changed the title [WIP] Decouple SwaggerRouter into Server and Sequence Decouple SwaggerRouter into HttpHandler and Sequence Jun 1, 2017
@bajtos bajtos requested a review from superkhau June 1, 2017 12:46
@bajtos
Copy link
Member Author

bajtos commented Jun 1, 2017

The pull request is ready for review.

@bajtos
Copy link
Member Author

bajtos commented Jun 1, 2017

Hmm, the code coverage is pretty bad, I'll need to add few more tests before this can be landed.

Here are the least covered files:

  • packages/core/src/parser.ts
  • packages/core/src/sequence.ts
  • packages/core/src/server.ts

Copy link
Contributor

@raymondfeng raymondfeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -30,7 +29,7 @@ describe('SwaggerRouter', () => {
givenControllerClass(HelloController, spec);
});

it('handles simple "GET /hello" requests', () => {
it('handles simple "GET /hello" requests', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove async

@superkhau superkhau force-pushed the decompose-router branch 3 times, most recently from 59d0e37 to 2764605 Compare June 1, 2017 20:58
@superkhau superkhau merged commit bbf6be3 into master Jun 1, 2017
@superkhau superkhau deleted the decompose-router branch June 1, 2017 21:22
@superkhau superkhau removed the review label Jun 1, 2017
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

3 participants