Skip to content

Commit

Permalink
Formatting changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Mar 8, 2019
1 parent e131c96 commit 8dc6676
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 46 deletions.
52 changes: 24 additions & 28 deletions core/src/main/java/io/sinistral/proteus/server/Extractors.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
*/
package io.sinistral.proteus.server;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.google.inject.Inject;
import io.sinistral.proteus.server.predicates.ServerPredicates;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.handlers.form.FormDataParser;
import io.undertow.util.HttpString;
import io.undertow.util.Methods;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
Expand All @@ -19,44 +32,27 @@
import java.util.Objects;
import java.util.function.Function;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.google.inject.Inject;

import io.sinistral.proteus.server.predicates.ServerPredicates;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.handlers.form.FormDataParser;
import io.undertow.util.HttpString;
import io.undertow.util.Methods;

/**
* @author jbauer
*/
public class Extractors
{
private static Logger log = LoggerFactory.getLogger(Extractors.class.getCanonicalName());

@Inject
@Inject
public static XmlMapper XML_MAPPER;

@Inject
@Inject
public static ObjectMapper OBJECT_MAPPER;

public static JsonNode parseJson(byte[] bytes) {
try
{
return OBJECT_MAPPER.readTree(bytes);
} catch (Exception e)
{
log.error(e.getMessage(),e);
return null;
}
};

public static JsonNode parseJson(byte[] bytes) {
try {
return OBJECT_MAPPER.readTree(bytes);
} catch (Exception e) {
log.error(e.getMessage(), e);
return null;
}
}

public static class Optional
{
Expand Down
26 changes: 8 additions & 18 deletions core/src/main/java/io/sinistral/proteus/server/ServerRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,9 @@
*/
public class ServerRequest
{
protected static final Receiver.ErrorCallback ERROR_CALLBACK = new Receiver.ErrorCallback()
{
@Override
public void error(HttpServerExchange exchange, IOException e)
{
exchange.putAttachment(DefaultResponseListener.EXCEPTION, e);
exchange.endExchange();
}
protected static final Receiver.ErrorCallback ERROR_CALLBACK = (exchange, e) -> {
exchange.putAttachment(DefaultResponseListener.EXCEPTION, e);
exchange.endExchange();
};

public static final AttachmentKey<ByteBuffer> BYTE_BUFFER_KEY = AttachmentKey.create(ByteBuffer.class);
Expand Down Expand Up @@ -109,16 +104,11 @@ public HttpServerExchange exchange()

private void extractBytes() throws IOException
{
this.exchange.getRequestReceiver().receiveFullBytes(new Receiver.FullBytesCallback()
{
@Override
public void handle(HttpServerExchange exchange, byte[] message)
{
ByteBuffer buffer = ByteBuffer.wrap(message);

exchange.putAttachment(BYTE_BUFFER_KEY, buffer);
}
},ERROR_CALLBACK);
this.exchange.getRequestReceiver().receiveFullBytes((exchange, message) -> {
ByteBuffer buffer = ByteBuffer.wrap(message);

exchange.putAttachment(BYTE_BUFFER_KEY, buffer);
},ERROR_CALLBACK);
}

private void extractFormParameters(final FormData formData)
Expand Down

0 comments on commit 8dc6676

Please sign in to comment.