The following table summarizes the annotations, their purpose and provides an example:
When a value is not specified to any binding annotation then the parameter name is used. In other words the following two methods are equivalent and both bind from a cookie called myCookie
:
@Get("/cookieName")
String cookieName(@CookieValue("myCookie") String myCookie) {
}
@Get("/cookieInferred")
String cookieInferred(@CookieValue String myCookie) {
// ...
@Get("/headerName")
public String headerName(@Header("Content-Type") String contentType) {
// ...
}
public String headerInferred(@Header String contentType) {
// ...
@Get("/headerName")
fun headerName(@Header("Content-Type") contentType: String): String {
// ...
}
@Get("/headerInferred")
fun headerInferred(@Header contentType: String): String {
// ...