I'm having trouble reading this line of scala in a legacy system I have inherited.
post("tokens" :: Auth() :: stringBody) { (_: String, token: String) =>
If it's required, I can post the lines before and after, but I assumed the line itself would have some meaning to a Scala developer.
The post method comes from the finch library, here is the method signature and comment:
/**
* A combinator that wraps the given [[Endpoint]] with additional check of the HTTP method. The
* resulting [[Endpoint]] succeeds on the request only if its method is `POST` and the underlying
* endpoint succeeds on it.
*/
def post[A](e: Endpoint[A]): EndpointMapper[A] = new EndpointMapper[A](Method.Post, e)
I assume the underscore is a match all for a string, but what is this matching? I assume it was matching the arguments in the post method, but there are three parameters and two things captured.
I assume the method matches to the "tokens" REST endpoint value, then expects an Auth header and captures the string body. I'm confused what the double colon argument means in this case, as it would be behaving different the first and second time it is used.