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

Tidy up styx-api module for 1.0 release #272

Merged
merged 3 commits into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/**
* All behaviour common to both full requests and full responses.
*/
public interface FullHttpMessage {
interface FullHttpMessage {
/**
* Returns the protocol version of this.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* All behaviour common to both streaming requests and streaming responses.
*/
public interface StreamingHttpMessage {
interface StreamingHttpMessage {
/**
* Returns the protocol version of this.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.hotels.styx.api.HttpInterceptor;
import com.hotels.styx.api.HttpRequest;
import com.hotels.styx.api.HttpResponse;
import com.hotels.styx.api.NoServiceConfiguredException;
import com.hotels.styx.server.NoServiceConfiguredException;
import com.hotels.styx.api.StyxObservable;
import com.hotels.styx.server.HttpRouter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.hotels.styx.api;
package com.hotels.styx;

import com.hotels.styx.api.HttpResponseStatus;

import static com.hotels.styx.api.HttpResponseStatus.statusWithCode;

/**
* Custom HTTP response status codes.
Expand All @@ -22,17 +26,17 @@ public final class CustomHttpResponseStatus {
/**
* 520 - Origin server timed out. This typically happens when the origin host is not serving pages. Please check your origin servers.
*/
public static final HttpResponseStatus ORIGIN_SERVER_TIMED_OUT = new HttpResponseStatus(520, "Origin server timed out");
public static final HttpResponseStatus ORIGIN_SERVER_TIMED_OUT = statusWithCode(520);

/**
* 521 - Indicates that the origin server refused the connection.
*/
public static final HttpResponseStatus ORIGIN_CONNECTION_REFUSED = new HttpResponseStatus(521, "Origin refused the connection");
public static final HttpResponseStatus ORIGIN_CONNECTION_REFUSED = statusWithCode(521);

/**
* 522 - Indicated that a server connection timed out.
*/
public static final HttpResponseStatus ORIGIN_CONNECTION_TIMED_OUT = new HttpResponseStatus(522, "Connection to origin timed out");
public static final HttpResponseStatus ORIGIN_CONNECTION_TIMED_OUT = statusWithCode(522);

private CustomHttpResponseStatus() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
import static com.hotels.styx.api.HttpResponseStatus.UNAUTHORIZED;
import static com.hotels.styx.api.HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE;
import static com.hotels.styx.proxy.HttpErrorStatusMetrics.formattedExceptionName;
import static com.hotels.styx.api.CustomHttpResponseStatus.ORIGIN_CONNECTION_REFUSED;
import static com.hotels.styx.api.CustomHttpResponseStatus.ORIGIN_CONNECTION_TIMED_OUT;
import static com.hotels.styx.api.CustomHttpResponseStatus.ORIGIN_SERVER_TIMED_OUT;
import static com.hotels.styx.CustomHttpResponseStatus.ORIGIN_CONNECTION_REFUSED;
import static com.hotels.styx.CustomHttpResponseStatus.ORIGIN_CONNECTION_TIMED_OUT;
import static com.hotels.styx.CustomHttpResponseStatus.ORIGIN_SERVER_TIMED_OUT;
import static java.lang.System.arraycopy;
import static java.util.stream.Collectors.toList;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.hotels.styx.api;
package com.hotels.styx.server;

import static java.lang.String.format;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.hotels.styx.api.HttpInterceptor;
import com.hotels.styx.api.HttpRequest;
import com.hotels.styx.api.HttpResponse;
import com.hotels.styx.api.NoServiceConfiguredException;
import com.hotels.styx.server.NoServiceConfiguredException;
import com.hotels.styx.api.StyxObservable;
import com.hotels.styx.api.HttpResponseStatus;
import com.hotels.styx.server.HttpErrorStatusListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.hotels.styx.api.HttpHandler;
import com.hotels.styx.api.HttpRequest;
import com.hotels.styx.api.HttpResponse;
import com.hotels.styx.api.StreamingHttpMessage;
import com.hotels.styx.api.StyxObservable;
import com.hotels.styx.api.plugins.spi.Plugin;
import com.hotels.styx.api.plugins.spi.PluginFactory;
Expand Down Expand Up @@ -73,7 +72,7 @@ public StyxObservable<HttpResponse> intercept(HttpRequest request, Chain chain)
.map(FullHttpResponse::toStreamingResponse);
}

private String xHcomPluginsHeader(StreamingHttpMessage message) {
private String xHcomPluginsHeader(HttpRequest message) {
return message.headers().get(X_HCOM_PLUGINS_HEADER).orElse("")
.concat(" test-plugin-a")
.trim();
Expand Down