带有喷雾is simple的HTTP GET示例:
import spray.routing.SimpleRoutingApp
object Main extends App with SimpleRoutingApp {
implicit val system = ActorSystem("my-system")
startServer(interface = "localhost", port = 8080) {
path("hello") {
get {
complete {
<h1>Say hello to spray</h1>
}
}
}
}
}
因此,如果我想执行HTTP POST,我可以使用post
指令。但是,我如何提供对所有HTTP方法的响应?像这样:
startServer(interface = "localhost", port = 8080) {
path("hello") {
all { // - here something like all derective
complete ("I do not care.")
}
}
}
是否有all
指令或类似内容?
答案 0 :(得分:2)
get
是一个过滤器指令,用于过滤HTTP方法,并且只允许通过。您不需要任何过滤器指令。
所以你可以根据HTTP方法获得任何过滤器指令
import spray.routing.SimpleRoutingApp
object Main extends App with SimpleRoutingApp {
implicit val system = ActorSystem("my-system")
startServer(interface = "localhost", port = 8080) {
path("hello") {
complete {
Say hello to spray
}
}
}
}