Skip to content

Instantly share code, notes, and snippets.

@lou-k
Created May 1, 2014 19:50
Show Gist options
  • Select an option

  • Save lou-k/ddbe5b0f5c83006b7bd1 to your computer and use it in GitHub Desktop.

Select an option

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
}
}
@lou-k

lou-k commented May 2, 2014

Copy link
Copy Markdown
Author

working with strings, baby!

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