what do you all think about this syntax for gettin...
# server
t
what do you all think about this syntax for getting header-values?
Copy code
val accept = request.headers.accept
val cacheControl = request.headers.cacheControl
val username = request.headers.authorization.basic.username
val password = request.headers.authorization.basic.password
b
It seems like your
request.headers
should just be value accessors whereas something else could handle the parsing of the headers
Copy code
when (request.authorization) {
    is BasicAuth -> {
        val username = request.authorization.username
        val password = request.authorization.password
    }
    is BearerAuth -> //handle oauth
    else -> // no auth parsed
}
request.authorization
could be a lazy property that runs the Authorization header through registered parsers
t
thanks @bdawg.io, that sounds like a good solution
i decided to skip the whole thing though
i added a simple object with constants instead
👍 1