Akka-http: How to get custom header from a request?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I send following headers in a request to my akka-http api: "Content-type": "application/json" , "Accept": "application/json" , "AppId": "some_id" . How do I get "AppId" custom header in my akka-http route? (get & parameters("id")) { (id) => complete { val appId = ?? // I want to get custom header here. } } Thanks. 回答1: You need to use one of the HeaderDirectives ( HeaderDirectives docs ) to extract the header. For example, if it's a custom one you can use headerValueByName which yields the value of the header, and rejects the route if the