Skip to content

Commit

Permalink
Update version. Add json routes.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Sep 21, 2017
1 parent 9f83467 commit 8de8ed6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.sinistral</groupId>
<artifactId>proteus-core</artifactId>
<version>0.1.7-SNAPSHOT</version>
<version>0.1.7.1-SNAPSHOT</version>
<name>proteus core</name>
<description>Proteus is an extremely light, fast, and flexible Java REST API framework built atop Undertow.</description>
<url>http://github.com/noboomu/proteus</url>
Expand Down
21 changes: 5 additions & 16 deletions src/main/java/io/sinistral/proteus/server/ServerRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
import java.util.Map;
import java.util.concurrent.Executor;

import org.xnio.Pool;
import org.xnio.Pooled;
import org.xnio.channels.StreamSourceChannel;

import io.sinistral.proteus.server.predicates.ServerPredicates;
import io.undertow.connector.PooledByteBuffer;
import io.undertow.security.api.SecurityContext;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.handlers.form.FormData;
Expand Down Expand Up @@ -143,10 +142,9 @@ private void extractBytes() throws IOException
{

this.exchange.startBlocking();


try (Pooled<ByteBuffer> pooled = exchange.getConnection().getBufferPool().allocate()){
ByteBuffer buf = pooled.getResource();

try (PooledByteBuffer pooled = exchange.getConnection().getByteBufferPool().getArrayBackedPool().allocate()){
ByteBuffer buf = pooled.getBuffer();

final StreamSourceChannel channel = this.exchange.getRequestChannel();

Expand All @@ -161,17 +159,8 @@ private void extractBytes() throws IOException
int pos = buf.limit();

ByteBuffer buffer = ByteBuffer.allocate(pos);

int nTransfer = Math.min(buffer.remaining(), buf.remaining());
if (nTransfer > 0)
{
buffer.put(buf.array(),
buf.arrayOffset()+buf.position(),
nTransfer);
buf.position(buf.position()+nTransfer);
}

// System.arraycopy(buf.array(), 0, buffer.array(), 0, pos);
System.arraycopy(buf.array(), 0, buffer.array(), 0, pos);

exchange.putAttachment(BYTE_BUFFER_KEY, buffer);

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/io/sinistral/proteus/server/ServerResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.jsoniter.output.JsonContext;
import com.jsoniter.output.JsonStream;

import io.sinistral.proteus.server.handlers.ServerDefaultResponseListener;
import io.sinistral.proteus.server.predicates.ServerPredicates;
import io.undertow.io.IoCallback;
import io.undertow.server.DefaultResponseListener;
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.handlers.Cookie;
Expand Down Expand Up @@ -335,7 +336,7 @@ public void send(final HttpHandler handler, final HttpServerExchange exchange) t
exchange.getResponseCookies().putAll(this.cookies);
}

exchange.setResponseCode(this.status);
exchange.setStatusCode(this.status);

if (this.contentType != null)
{
Expand All @@ -357,7 +358,7 @@ else if (ServerPredicates.ACCEPT_XML_PREDICATE.resolve(exchange))

if (hasError)
{
exchange.putAttachment(ServerDefaultResponseListener.EXCEPTION, throwable);
exchange.putAttachment(DefaultResponseListener.EXCEPTION, throwable);

return;
}
Expand Down

0 comments on commit 8de8ed6

Please sign in to comment.