-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Enable returning a Mutiny Buffer from RESTEasy Reactive Resource Method
- Loading branch information
Showing
6 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...jboss/resteasy/reactive/server/vertx/serializers/ServerMutinyBufferMessageBodyWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.jboss.resteasy.reactive.server.vertx.serializers; | ||
|
||
import io.vertx.mutiny.core.buffer.Buffer; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Type; | ||
import javax.ws.rs.WebApplicationException; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.MultivaluedMap; | ||
import javax.ws.rs.ext.Provider; | ||
import org.jboss.resteasy.reactive.server.spi.ResteasyReactiveResourceInfo; | ||
import org.jboss.resteasy.reactive.server.spi.ServerMessageBodyWriter; | ||
import org.jboss.resteasy.reactive.server.spi.ServerRequestContext; | ||
|
||
@Provider | ||
public class ServerMutinyBufferMessageBodyWriter implements ServerMessageBodyWriter<Buffer> { | ||
|
||
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { | ||
return true; | ||
} | ||
|
||
public void writeTo(Buffer buffer, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, | ||
MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { | ||
entityStream.write(buffer.getBytes()); | ||
} | ||
|
||
@Override | ||
public boolean isWriteable(Class<?> type, Type genericType, ResteasyReactiveResourceInfo target, MediaType mediaType) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void writeResponse(Buffer buffer, Type genericType, ServerRequestContext context) throws WebApplicationException { | ||
context.serverResponse().end(buffer.getBytes()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters