Created
May 1, 2014 19:50
-
-
Save lou-k/ddbe5b0f5c83006b7bd1 to your computer and use it in GitHub Desktop.
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
class PimpedDispatchRequest(req: Request) { | |
private val HEADER_FORMAT = "--header '%s: %s'" | |
def toCurl(): String = { | |
"curl " + | |
req.headers.map({ | |
case (name, value) => HEADER_FORMAT.format(name, value) | |
}).mkString(" ") + | |
req.body.map(EntityUtils.toString).map(" --data '%s' ".format(_)).getOrElse("") + | |
" " + | |
req.host + req.path | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is without a doubt the ugliest formatting code I've ever seen in my life. 👍