forked from graphhopper/graphhopper
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finally get dropwizard 4.0.7 working
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
web-bundle/src/main/java/com/graphhopper/http/GpxMessageBodyReader.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,30 @@ | ||
package com.graphhopper.http; | ||
|
||
import com.fasterxml.jackson.dataformat.xml.XmlMapper; | ||
import com.graphhopper.jackson.Gpx; | ||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.ext.Provider; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.MultivaluedMap; | ||
import jakarta.ws.rs.ext.MessageBodyReader; | ||
import java.io.InputStream; | ||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Type; | ||
import java.io.IOException; | ||
|
||
@Provider | ||
@Consumes({"application/gpx+xml", "application/xml"}) | ||
public class GpxMessageBodyReader implements MessageBodyReader<Gpx> { | ||
final private XmlMapper xmlMapper = new XmlMapper(); | ||
@Override | ||
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { | ||
return type == Gpx.class; | ||
} | ||
|
||
@Override | ||
public Gpx readFrom(Class<Gpx> type, Type genericType, Annotation[] annotations, MediaType mediaType, | ||
MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException | ||
{ | ||
return xmlMapper.readValue(entityStream, Gpx.class); | ||
} | ||
} |
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