Skip to content

Support java.time formatters in Router handlers #4

@danneu

Description

@danneu

It would be nice to have type-safe routes that only match if the provided formatter can parse the param.

e.g. This would be cool:

val router = Router {
    get("/when/<start>/<end>", fun(start: kog.ZonedDateTime("yyyy MM DD Z")) = ...)
    get("/when/<start>/<end>", fun(start: kog.ZonedDateTime(DateTimeFormatter.ISO_INSTANT)) = ...)
}

Impl idea: wrap java.time constructs myself so that the user can specify kog.ZonedDateTime(Formatter) like above and then start.get() to unwrap them back into java.time constructs. Or instead of wrapping construct, provide an interface that user can extend.

Basically need user to provide the destination class and a formatter that attempts to parse param into that object.

Reminder: http://blog.joda.org/2014/11/converting-from-joda-time-to-javatime.html

A Hex matcher would be nice, too. e.g. hashes.

Consider a way to support arbitrary loaders like get("/users/<id>", fun(user: User) = ...).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions