spray/spray-template — pull request #26 by ttyusupov (2014-05-21 21:56:55+00:00)
Title: example of detach and future for asynchronous request processing

This PR demonstrates strange behavior of detach spray directive.

For detach (https://github.com/ttyusupov/spray-template/blob/ty-detach-example/src/main/scala/com/example/MyService.scala#L44) processing is done within the same thread as routing:
```shell
$ curl http://localhost:8080/test-detach/1
OK
```
logs:
```
detach-out on-spray-can-akka.actor.default-dispatcher-4
detach-in-1 on-spray-can-akka.actor.default-dispatcher-4
detach-in-2 on-spray-can-akka.actor.default-dispatcher-4
```

For future (https://github.com/ttyusupov/spray-template/blob/ty-detach-example/src/main/scala/com/example/MyService.scala#L55) processing is done concurrently in separate thread:
```shell
$ curl http://localhost:8080/test-detach/1
OK
```
logs:
```
future-out on-spray-can-akka.actor.default-dispatcher-7
future-out-2 on-spray-can-akka.actor.default-dispatcher-7
future-in-1 ForkJoinPool-2-worker-7
future-in-2 ForkJoinPool-2-worker-7
```