Header Param
Adds a single HTTP header whose value is provided at call time.
The value
parameter specifies only the header name. The header value is taken from the annotated function parameter.
@GET("comment")
suspend fun getComment(@HeaderParam("Authorization") token: String): Comment
@GET("comments")
suspend fun getComments(
@HeaderParam(Header.Authorization) token: String, // type safe
): List<Comment>
// Call:
getComments(token = "Bearer superSecureToken")
// Resulting header: "Authorization: Bearer superSecureToken"
Content copied to clipboard
By default, Headers do not overwrite each other: all headers with the same name will be included in the request. Except headers mentioned as singleton, e.g. Content-Type