I am new to Scala and spray. I wrote a simple REST API in accordance with the instructions given in this blog post. http://www.smartjava.org/content/first-steps-rest-spray-and-scala
And everything works as expected.
Now I want to change the program for printing HTTP headers such as encoding, language, remote address, etc. I would like to print all the header information (the goal is to record this data)
But I could not find the correct documentation or examples. Can anyone help me do this.
:
optionalHeaderValueByName("Encoding") { encodingHeader => println(encodingHeader) complete("hello") }
. , :
def logHeaders(): Directive0 = extract(_.request.headers).map(println)
logHeaders() { complete("hello") }
.
def logHeaders(innerRoute: Route): (RequestContext => Unit) = extract(_.request.headers) { headers => headers.foreach(h => logger.info("header: {} = {}", h.name, h.value)) innerRoute }
Source: https://habr.com/ru/post/1607252/More articles:Как установить VIM со всеми параметрами/функциями? - VIM - vimWhat is the pronunciation of vim? - vimquick quick listing of options - swiftFinding points in a 2D area - pythonInterrupt and restart write operation - pythonInstalling the Lync 2013 sdk client side at visual studio 2015 - visual-studioIs it not possible to call untie? - c ++Разработайте с помощью Lync 2013 SDK в сообществе Visual Studio 2015? - visual-studioCSS import fonts - htmlhow to use gulp wrench plugin - gulpAll Articles