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

HttpService.orElse(HttpService) #60

Merged
merged 1 commit into from
Dec 5, 2015
Merged

Conversation

trustin
Copy link
Member

@trustin trustin commented Dec 3, 2015

Motivation:

It is often useful to serve some resources in one HttpService and other
resources in the other HttpService. There's no way to bind such 2
services under the same path prefix.

Modifications:

  • Add HttpService.orElse() so that a user can compose two HttpService
    into one
  • Test HttpService.orElse() using HttpFileServices
  • Move the resources used by HttpFileServiceTest to an appropriate
    directory

Result:

A user can combine two HttpServices:

virtualHost.serviceUnder(
        "/foo",
        HttpFileService.for(...).orElse(TomcatService.for(...)));

if (nextSubHandler != null && res.status().code() == HttpResponseStatus.NOT_FOUND.code()) {
// The current sub-handler returned 404. Try the next sub-handler.
res.release();
if (!promise.isDone()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wondering, when could this be true? Something like idle timeout?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.

Copy link
Member Author

Choose a reason for hiding this comment

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

or unexpectedly closed connections.

@trustin trustin force-pushed the better_404 branch 2 times, most recently from 898beb9 to 2ebb99a Compare December 4, 2015 12:16
invoke0(ctx, blockingTaskExecutor, promise, first, second);
}

private void invoke0(ServiceInvocationContext ctx, Executor blockingTaskExecutor, Promise<Object> promise,
Copy link
Contributor

Choose a reason for hiding this comment

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

over 112 columns?

@delegacy
Copy link
Contributor

delegacy commented Dec 5, 2015

Found some longer lines... 😭

Motivation:

It is often useful to serve some resources in one HttpService and other
resources in the other HttpService. There's no way to bind such 2
services under the same path prefix.

Modifications:

- Add HttpService.orElse() so that a user can compose two HttpService
  into one
- Test HttpService.orElse() using HttpFileServices
- Move the resources used by HttpFileServiceTest to an appropriate
  directory

Result:

A user can combine two HttpServices:

    virtualHost.serviceUnder(
            "/foo",
            HttpFileService.for(...).orElse(TomcatService.for(...)));
@trustin
Copy link
Member Author

trustin commented Dec 5, 2015

@delegacy Fixed :-)

@delegacy
Copy link
Contributor

delegacy commented Dec 5, 2015

👍 Let's ship it.

delegacy added a commit that referenced this pull request Dec 5, 2015
HttpService.orElse(HttpService)
@delegacy delegacy merged commit 2a4f1f3 into line:master Dec 5, 2015
@trustin trustin deleted the better_404 branch December 7, 2015 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants