2

I have a Dispatch 0.8 DELETE handler that needs to have a body.

So I have a normal DELETE that works fine:

def delete = request.DELETE  ># identity

I tried this:

def delete(body: String) = request.DELETE <<< body ># identity

but it turned the request into a PUT because of the <<< operator.

Urist McDev
  • 498
  • 3
  • 14
DorkRawk
  • 732
  • 2
  • 6
  • 21
  • I found this question because I am facing a similar problem, and the manual (Kelsey cites it below) is pretty cryptic and didn't help. There's a blog post here https://bhudgeons.telegr.am/blog_posts/handling-non-standard-urls-in-dispatch# that does explain how to access the RequestBuilder which is a start – Mark Butler Aug 07 '14 at 15:44

2 Answers2

2

Use setBody instead: "If you wish to supply a string instead of a file, use a setBody method of the RequestBuilder class. Its variants support a number of input types and do not imply a particular HTTP method." from http://dispatch.databinder.net/HTTP+methods+and+parameters.html

1

To do this with Dispatch 0.8, I used a sort of hacky solution:

def delete(body: String) = (request << body).DELETE ># identity 
DorkRawk
  • 732
  • 2
  • 6
  • 21