Skip to content

Instantly share code, notes, and snippets.

@lou-k
Created May 1, 2014 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lou-k/ddbe5b0f5c83006b7bd1 to your computer and use it in GitHub Desktop.
Save lou-k/ddbe5b0f5c83006b7bd1 to your computer and use it in GitHub Desktop.
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
}
}
@duane
Copy link

duane commented May 1, 2014

This is without a doubt the ugliest formatting code I've ever seen in my life. 👍

@lou-k
Copy link
Author

lou-k commented May 2, 2014

working with strings, baby!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment