Skip to content
Permalink
Browse files

[tutorial-5] Added an example of completing a future of unit for @ktoso

  • Loading branch information...
DanielaSfregola committed Feb 10, 2016
1 parent 79a48a5 commit e0cc6c6e0815b596ffd2caf5eaca6c6023a20aba
@@ -6,6 +6,8 @@ import com.danielasfregola.quiz.management.entities.{Question, QuestionUpdate}
import com.danielasfregola.quiz.management.routing.MyResource
import com.danielasfregola.quiz.management.services.QuestionService

import scala.concurrent.Future

trait QuestionResource extends MyResource {

val questionService: QuestionService
@@ -30,7 +32,8 @@ trait QuestionResource extends MyResource {
}
} ~
delete {
complete(questionService.deleteQuestion(id))
complete(Future(()))

This comment has been minimized.

Copy link
@ktoso

ktoso Feb 15, 2016

Now I see why this renders for you. It's not an Akka HTTP thing though, it's how Heiko's library provides marshallers, this one triggers:

implicit def json4sMarshaller[A <: AnyRef](implicit serialization: Serialization, formats: Formats, shouldWritePretty: ShouldWritePretty = ShouldWritePretty.False): ToEntityMarshaller[A] =

from de.heikoseeberger.akkahttpjson4s.Json4sSupport. So it's a 3rd party lib that makes the () render as you noticed, not any Akka HTTP defaults. If possible it would be great if you could amend the blog post to explain that :-) Our defaults certainly don't provide default marshallers for this case yet it sounds so from the context of your blog post :)

This comment has been minimized.

Copy link
@DanielaSfregola

DanielaSfregola Feb 15, 2016

Author Owner

Thank you very much! It does make sense now.

I'll update my blog post asap :)

You're the best! 💃

This comment has been minimized.

Copy link
@ktoso

ktoso Feb 15, 2016

Glad this helped explain the mystery :-)
Thanks for updating the blog, you rock!

This comment has been minimized.

Copy link
@jrudolph

jrudolph Feb 16, 2016

That's something we stumbled over in the past as well (e.g. spray/spray#990 (comment)) in other instances.

FTR here's the bug report in akka-http-json: hseeberger/akka-http-json#52

// complete(questionService.deleteQuestion(id))
}
}

@@ -33,6 +33,6 @@ trait MyResource extends Directives with JsonSupport {
case None => complete(404, None)
}

def complete(resource: Future[Unit]): Route = onSuccess(resource) { complete(204, None) }
// def complete(resource: Future[Unit]): Route = onSuccess(resource) { complete(204, None) }

}

0 comments on commit e0cc6c6

Please sign in to comment.
You can’t perform that action at this time.