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

Add Transformer class for live HTTP objects #328

Merged
merged 4 commits into from
Oct 30, 2018

Conversation

mikkokar
Copy link
Contributor

@mikkokar mikkokar commented Oct 25, 2018

To make Styx APIs safer for the end-users, this PR adds a separate Transformer alongside Builder in LiveHttpRequest and LiveHttpResponse classes. The transformer restricts what the API consumers can do 1) when creating a new live HTTP object and 2) when transforming one.

Some examples:

It is no longer possible to replace, and thus disconnect the reactive ByteStream chain like so:

    response().build()
            .newBuilder()
            .body(new ByteStream(...)).   // No longer available
            .build();

The transformer class now enforces API consumers to transform the byte stream with the lambda alternative. Like so:

    response().build()
            .newBuilder()
            .body(ByteStream::drop)
            .build();

Likewise it is no longer possible to supply a mapper lambda when creating a live object. This is no longer possible:

    response()
            .body(stream -> doSomething(stream))  // No longer available
            .build();

* Remove AsyncRequestContentSpec and AsyncResponseContentSpec e2e tests because
  asynchronous content transformation is not yet supported in 1.0 API.
@mikkokar mikkokar merged commit 0a68f10 into ExpediaGroup:master Oct 30, 2018
@mikkokar mikkokar deleted the api1-builder-transformer branch October 30, 2018 10:10
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.

2 participants