diff --git a/conf/logback.xml b/conf/logback.xml
index 5347c64..7e1a78f 100644
--- a/conf/logback.xml
+++ b/conf/logback.xml
@@ -20,9 +20,11 @@
-
+
+
+ io.sinistral.proteus.services
@@ -98,11 +100,7 @@
-
-
-
-
-
+
diff --git a/pom.xml b/pom.xml
index 3ae88c2..2a70800 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,10 +25,26 @@
testCompile
+
-
+
+
@@ -77,7 +93,6 @@
1.6.0
-
exec
@@ -124,30 +139,44 @@
true
lib/
io.sinistral.proteus.Application
+
+
-
- junit
- junit
- 4.12
- test
-
- io.rest-assured
- rest-assured
- 3.0.2
- test
+ junit
+ junit
+ 4.12
+
+
+ io.rest-assured
+ rest-assured
+ 3.0.2
+ test
org.mortbay.jetty.alpn
alpn-boot
8.1.11.v20170118
- runtime
+ runtime
@@ -340,13 +369,24 @@
io.sinistral
jsoniter
- 0.9.8
+ 0.9.9-SNAPSHOT
com.github.javaparser
javaparser-core
[3.2.0,)
+
UTF-8
diff --git a/src/main/java/io/sinistral/proteus/controllers/Benchmarks.java b/src/main/java/io/sinistral/proteus/controllers/Benchmarks.java
index 1fbb5ed..350f47b 100644
--- a/src/main/java/io/sinistral/proteus/controllers/Benchmarks.java
+++ b/src/main/java/io/sinistral/proteus/controllers/Benchmarks.java
@@ -5,23 +5,30 @@
import static io.sinistral.proteus.server.ServerResponse.response;
-import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
+
+import org.xnio.channels.Channels;
+import org.xnio.conduits.StreamSinkConduit;
+
import com.google.common.collect.ImmutableMap;
import com.google.inject.Singleton;
import com.jsoniter.output.JsonStream;
-import io.sinistral.proteus.models.User;
import io.sinistral.proteus.models.World;
import io.sinistral.proteus.server.ServerResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
+import io.undertow.io.UndertowOutputStream;
import io.undertow.server.HttpServerExchange;
+import io.undertow.server.protocol.http.HttpServerConnection;
+import io.undertow.util.Headers;
/**
* @author jbauer
@@ -52,6 +59,8 @@ public void json2(HttpServerExchange exchange)
response( JsonStream.serializeToBytes(ImmutableMap.of("message", "Hello, World!")) ).applicationJson().send(exchange);
}
+
+
@GET
@Path("/world")
@ApiOperation(value = "World serialization endpoint", httpMethod = "GET", response = World.class )
diff --git a/src/main/java/io/sinistral/proteus/server/ServerResponse.java b/src/main/java/io/sinistral/proteus/server/ServerResponse.java
index 8ffd675..5d0db33 100644
--- a/src/main/java/io/sinistral/proteus/server/ServerResponse.java
+++ b/src/main/java/io/sinistral/proteus/server/ServerResponse.java
@@ -3,7 +3,9 @@
*/
package io.sinistral.proteus.server;
+import java.io.OutputStream;
import java.nio.ByteBuffer;
+import java.nio.channels.Channels;
import java.util.HashMap;
import java.util.Map;
@@ -11,16 +13,12 @@
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.jsoniter.any.Any;
import com.jsoniter.output.JsonContext;
import com.jsoniter.output.JsonStream;
-import com.jsoniter.spi.Encoder;
import io.sinistral.proteus.server.predicates.ServerPredicates;
-import io.undertow.attribute.ExchangeAttributes;
+import io.undertow.io.AsyncSenderImpl;
import io.undertow.io.IoCallback;
-import io.undertow.predicate.Predicate;
-import io.undertow.predicate.Predicates;
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.handlers.Cookie;
@@ -378,16 +376,8 @@ else if (hasEntity)
}
else
{
- try
- {
- exchange.getResponseSender().send(JsonStream.serialize(this.entity, this.jsonContext));
- } catch (Exception e)
- {
- log.error(e.getMessage() + " for entity " + this.entity, e);
-
- throw new IllegalArgumentException(e);
- }
-
+
+ exchange.getResponseSender().send(JsonStream.serializeToBytes(this.entity, this.jsonContext));
}
} catch (Exception e)
diff --git a/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java b/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java
index 35bf1a8..07f82c7 100644
--- a/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java
+++ b/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java
@@ -10,7 +10,6 @@
import java.lang.reflect.Type;
import java.net.URI;
import java.net.URL;
-import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -511,7 +510,7 @@ public Class extends Supplier> compileClass()
this.generateRoutes();
- log.info("\n\nGenerated Class Source:\n\n" + this.sourceString);
+ log.debug("\n\nGenerated Class Source:\n\n" + this.sourceString);
// CompilerUtils.addClassPath("./lib");
return CompilerUtils.CACHED_COMPILER.loadFromJava(packageName + "." + className, this.sourceString);
diff --git a/src/main/java/io/sinistral/proteus/services/SwaggerService.java b/src/main/java/io/sinistral/proteus/services/SwaggerService.java
index 2f4f669..c486da5 100644
--- a/src/main/java/io/sinistral/proteus/services/SwaggerService.java
+++ b/src/main/java/io/sinistral/proteus/services/SwaggerService.java
@@ -15,6 +15,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
+import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.mitchellbosecke.pebble.PebbleEngine;
@@ -41,14 +44,12 @@
public class SwaggerService extends BaseService implements Supplier
{
-
-
-
+
private static Logger log = LoggerFactory.getLogger(SwaggerService.class.getCanonicalName());
protected io.sinistral.proteus.server.swagger.Reader reader = null;
- protected String swaggerResourcePath = "./swagger";
+ protected final String swaggerResourcePath = "./swagger";
protected final String swaggerThemesPath = "./swagger/themes";
@@ -158,8 +159,20 @@ public void generateSwaggerSpec()
this.swagger = this.reader.getSwagger();
- this.swaggerSpec = JsonMapper.toPrettyJSON(this.swagger);
+ ObjectMapper mapper = new ObjectMapper();
+ ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
+ writer.without(SerializationFeature.WRITE_NULL_MAP_VALUES);
+ try
+ {
+
+ this.swaggerSpec = writer.writeValueAsString(this.swagger);
+
+ } catch (Exception e)
+ {
+ log.error(e.getMessage(),e);
+ }
+
}
@@ -186,6 +199,8 @@ public void generateSwaggerHTML()
{
try
{
+
+
PebbleEngine engine = new PebbleEngine.Builder().build();
PebbleTemplate compiledTemplate = engine.getTemplate("swagger/index.html");