From b131119887b8d430db80bb118a9cd9e8a4b636d5 Mon Sep 17 00:00:00 2001 From: Joshua Bauer Date: Tue, 16 Jun 2020 14:39:52 -0700 Subject: [PATCH] Added protocol package and custom HttpHeaders implementation. --- CHANGELOG.md | 5 + .../sinistral/proteus/ProteusApplication.java | 6 +- .../proteus/protocol/HttpHeaders.java | 183 ++++++++++++++++++ .../{server => protocol}/MediaType.java | 3 +- .../proteus/server/ServerResponse.java | 1 + .../server/predicates/ServerPredicates.java | 2 +- .../proteus/services/DefaultService.java | 3 + .../proteus/openapi/jaxrs2/Reader.java | 12 ++ .../openapi/services/OpenAPIService.java | 6 +- .../swagger/services/SwaggerService.java | 6 +- 10 files changed, 215 insertions(+), 12 deletions(-) create mode 100644 proteus-core/src/main/java/io/sinistral/proteus/protocol/HttpHeaders.java rename proteus-core/src/main/java/io/sinistral/proteus/{server => protocol}/MediaType.java (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1dcbcc..21aae3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ Proteus Changelog. ## Unreleased ### No issue +**Break out XmlModule** + + +[cf6d3c9b4a93457](https://github.com/noboomu/proteus/commit/cf6d3c9b4a93457) Joshua Bauer *2020-05-15 00:05:32* + **Incorrect File.sep() use - broken on Windows.** * On Windows: diff --git a/proteus-core/src/main/java/io/sinistral/proteus/ProteusApplication.java b/proteus-core/src/main/java/io/sinistral/proteus/ProteusApplication.java index 5fb8e74..d74878d 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/ProteusApplication.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/ProteusApplication.java @@ -380,7 +380,7 @@ public ProteusApplication addDefaultRoutes(RoutingHandler router) this.registeredEndpoints.add(EndpointInfo.builder().withConsumes("*/*").withProduces("text/plain").withPathTemplate(statusPath).withControllerName("Internal").withMethod(Methods.GET).build()); } catch (Exception e) { - log.error("Error adding health status route.", e.getMessage()); + log.error("Error adding health status route.", e); } } @@ -426,12 +426,12 @@ public ProteusApplication addDefaultRoutes(RoutingHandler router) router.add(Methods.GET, "favicon.ico", (final HttpServerExchange exchange) -> { - exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, io.sinistral.proteus.server.MediaType.IMAGE_X_ICON.toString()); + exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, io.sinistral.proteus.protocol.MediaType.IMAGE_X_ICON.toString()); exchange.getResponseSender().send(faviconImageBuffer); }); } catch (Exception e) { - log.error("Error adding favicon route.", e.getMessage()); + log.error("Error adding favicon route.", e); } } diff --git a/proteus-core/src/main/java/io/sinistral/proteus/protocol/HttpHeaders.java b/proteus-core/src/main/java/io/sinistral/proteus/protocol/HttpHeaders.java new file mode 100644 index 0000000..4ffbfaa --- /dev/null +++ b/proteus-core/src/main/java/io/sinistral/proteus/protocol/HttpHeaders.java @@ -0,0 +1,183 @@ +package io.sinistral.proteus.protocol; + +/** + * Base copied from org.apache.http.HttpHeaaders + */ + +public final class HttpHeaders { + public static final String ACCEPT = "Accept"; + public static final String ACCEPT_CH = "Accept-CH"; + public static final String ACCEPT_CHARSET = "Accept-Charset"; + public static final String ACCEPT_CH_LIFETIME = "Accept-CH-Lifetime"; + public static final String ACCEPT_ENCODING = "Accept-Encoding"; + public static final String ACCEPT_LANGUAGE = "Accept-Language"; + public static final String ACCEPT_PUSH_POLICY = "Accept-Push-Policy"; + public static final String ACCEPT_RANGES = "Accept-Ranges"; + public static final String ACCEPT_SIGNATURE = "Accept-Signature"; + public static final String ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials"; + public static final String ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers"; + public static final String ACCESS_CONTROL_ALLOW_METHODS = "Access-Control-Allow-Methods"; + public static final String ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin"; + public static final String ACCESS_CONTROL_EXPOSE_HEADERS = "Access-Control-Expose-Headers"; + public static final String ACCESS_CONTROL_MAX_AGE = "Access-Control-Max-Age"; + public static final String ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers"; + public static final String ACCESS_CONTROL_REQUEST_METHOD = "Access-Control-Request-Method"; + public static final String AGE = "Age"; + public static final String ALLOW = "Allow"; + public static final String ALT_SVC = "Alt-Svc"; + public static final String AUDIO = "audio"; + public static final String AUDIOWORKLET = "audioworklet"; + public static final String AUTHORIZATION = "Authorization"; + public static final String Access_Control_Allow_Headers = "Access-Control-Allow-Headers"; + public static final String CACHE_CONTROL = "Cache-Control"; + public static final String CLEAR_SITE_DATA = "Clear-Site-Data"; + public static final String CONNECTION = "Connection"; + public static final String CONTENT_DISPOSITION = "Content-Disposition"; + public static final String CONTENT_DPR = "Content-DPR"; + public static final String CONTENT_ENCODING = "Content-Encoding"; + public static final String CONTENT_LANGUAGE = "Content-Language"; + public static final String CONTENT_LENGTH = "Content-Length"; + public static final String CONTENT_LOCATION = "Content-Location"; + public static final String CONTENT_MD5 = "Content-MD5"; + public static final String CONTENT_RANGE = "Content-Range"; + public static final String CONTENT_SECURITY_POLICY = "Content-Security-Policy"; + public static final String CONTENT_SECURITY_POLICY_REPORT_ONLY = "Content-Security-Policy-Report-Only"; + public static final String CONTENT_TYPE = "Content-Type"; + public static final String COOKIE = "Cookie"; + public static final String COOKIE2 = "Cookie2"; + public static final String CORS = "cors"; + public static final String CROSSDOMAIN_XML = "crossdomain.xml"; + public static final String CROSS_ORIGIN_EMBEDDER_POLICY = "Cross-Origin-Embedder-Policy"; + public static final String CROSS_ORIGIN_OPENER_POLICY = "Cross-Origin-Opener-Policy"; + public static final String CROSS_ORIGIN_RESOURCE_POLICY = "Cross-Origin-Resource-Policy"; + public static final String CROSS_SITE = "cross-site"; + public static final String DATE = "Date"; + public static final String DAV = "Dav"; + public static final String DEPTH = "Depth"; + public static final String DESTINATION = "Destination"; + public static final String DEVICE_MEMORY = "Device-Memory"; + public static final String DNT = "DNT"; + public static final String DOCUMENT = "document"; + public static final String DPR = "DPR"; + public static final String EARLY_DATA = "Early-Data"; + public static final String EMBED = ""; + public static final String EMPTY = "empty"; + public static final String ETAG = "ETag"; + public static final String EXPECT = "Expect"; + public static final String EXPECT_CT = "Expect-CT"; + public static final String EXPIRES = "Expires"; + public static final String FEATURE_POLICY = "Feature-Policy"; + public static final String FONT = "font"; + public static final String FORWARDED = "Forwarded"; + public static final String FRAME = ""; + public static final String FROM = "From"; + public static final String HOST = "Host"; + public static final String HTTP_EQUIV = "http-equiv"; + public static final String IF = "If"; + public static final String IFRAME = "