Hi, there's some things that can be improved here (I'll follow up later), however the first thing that confused me:
You mention (and handle) text/plain everywhere, yet your CURL example is about text/csv - which is different so I'd expect the 404 actually. Is that a typo or the actual question? -- Cheers, Konrad 'ktoso’ Malawski Akka @ Lightbend On 18 March 2016 at 12:58:11, Christian Pérez-Llamas (chri...@gmail.com) wrote: Hi, I am doing my first steps with Akka HTTP with no previous experience with Spray. I need to implement a POST that can accept either text/plain or application/json and returns application/json. I am using akka-http-json library for marshalling/unmarshalling json. This is the part of the route that deals with it: path("things") { post { decodeRequest { request.entity.contentType.mediaType match { case MediaTypes.`text/plain` => import PredefinedFromEntityUnmarshallers.stringUnmarshaller entity(as[String]) { body => // Every line can contain things, empty lines or comments complete { Source.fromString(body).getLines .map(_.trim) .filterNot(line => line.isEmpty || line.startsWith("#")) .toSeq } } case MediaTypes.`application/json` => entity(as[List[Thing]]) { things => complete(things.map(_.name)) } case _ => reject } } } } When I do a request with curl with 'Content-Type:text/csv' for example I get a: HTTP/1.1 404 Not Found The requested resource could not be found. My gut intuition tells me that I am not doing the media type multiplexing the right way. What is the idiomatic way to handle different media types ?, and how can I specify the allowed ContentTypes (or media types) so the response error is more specific ? Thank you very much, Christian -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout. -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.