Scala 使用 post 方法关闭 akka-http 服务器

Scala shutwodn akka-htpp server with post method

不明白为什么我不能关闭 akka-http 服务器。

有下一个代码:

   path("api" / "system" / "shutdown") {
     logger.warning("shutting down insights application")
     appLifecycle.shutdown()
     complete(JsObject(Map("status" -> JsString("shutting_down"))))
   }
 }

def shutdown(): Unit                         = actor ! Shutdown

结果,我收到了下一条消息 -> The requested resource could not be found inside chrome 我还在终端内收到了下一条消息 -> com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input at [Source: java.io.StringReader@421ea4c0; line: 1, column: 1]

有什么想法吗?

首先我认为你应该添加一个 post 指令,然后你应该这样做:

system.terminate()

或:

actor ! Kill // or PoisonPill