Created
December 9, 2011 02:29
-
-
Save takezoe/1449859 to your computer and use it in GitHub Desktop.
XML response with Unfiltered
This file contains hidden or 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
import unfiltered.request._ | |
import unfiltered.response._ | |
import scala.xml._ | |
case class Xml(nodes: NodeSeq) | |
extends ComposeResponse(TextXmlContent ~> ResponseString(nodes.toString)) | |
// Usage | |
def intent = { | |
case GET(Path(Seg("hello" :: name :: Nil))) => { | |
Ok ~> Xml(<hello>{name}</hello>) | |
} | |
} |
名前は Html だけれども、結局 scala.xml.NodeSeq
型でつまり xml だからこれでいいんじゃないですかね?
あ、でも type 違うのか・・・
これだと中でHtmlContentがチェインされているのでContent-Typeがtext/htmlになってしまうのです…。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I couldn't find a case class to response XML in the Unfiltered librariy.
It might be good if classes such as this example are included in the Unfiltered library.