This includes most common Java types, however additional instances can be registered simply be creating beans of type TypeConverter.

    1. @Get("/headerInferred")
    2. String headerInferred(@Header String contentType) {
    3. // ...
    4. }
    1. @Get("/headerInferred")
    2. fun headerInferred(@Header contentType: String): String {
    3. // ...
    4. }

    In this case if the HTTP header Content-Type is not present in the request the route is considered invalid, since it cannot be satisfied and a HTTP 400 BAD REQUEST is returned.

    1. String headerNullable(@Nullable @Header String contentType) {
    2. }
    1. @Get("/headerNullable")
    2. fun headerNullable(@Header contentType: String?): String? {
    3. // ...
    4. }

    An null string will be passed if the header is absent from the request.

    1. @Get("/date")
    2. String date(@Header ZonedDateTime date) {
    3. // ...
    4. String dateFormat(@Format("dd/MM/yyyy hh:mm:ss a z") @Header ZonedDateTime date) {
    5. // ...
    6. }
    1. @Get("/date")
    2. fun date(@Header date: ZonedDateTime): String {
    3. // ...
    4. }
    5. @Get("/dateFormat")
    6. fun dateFormat(@Format("dd/MM/yyyy hh:mm:ss a z") @Header date: ZonedDateTime): String {
    7. }