Home Java Akka HTTP request parameter extraction
Reply: 0

Java Akka HTTP request parameter extraction

user1280 Published in May 21, 2018, 4:49 pm

I would like to create a route with Java and akka for PUT/PATCH requests such as:


for example:

/item/c72d9e07-d5b6-4eb6-8d73-60b4451539f4/{"name":"hello world"}

I have tried something like this but the UUID is no longer accessible in the inner route handler:

 pathPrefix("item", () ->
                path(PathMatchers.uuidSegment(), (UUID itemId) ->
                        PathMatchers.remaining(), (String json) ->

                        // PATCH        
                        patch(() ->
                            entity(Jackson.unmarshaller(ItemResource.class), item -> {
                                            return updateItem(itemId,item);

(It does not compile because itemId is not accessible anymore when calling updateItem)

I am an akka novice so any help appreciated.

UPDATE: I see that the following is possible:

path(PathMatchers.uuidSegment().slash(PathMatchers.segment()), (UUID itemId, String json) -> { //complete route here }

However the json is not extracted correctly just yet (json="")

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.321677 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO