Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support java.time formatters in Router handlers #4

Open
danneu opened this issue Jan 14, 2017 · 0 comments
Open

Support java.time formatters in Router handlers #4

danneu opened this issue Jan 14, 2017 · 0 comments
Labels

Comments

@danneu
Copy link
Owner

danneu commented Jan 14, 2017

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) = ...).

@danneu danneu changed the title Support DateTime formatters in SafeRouter handlers Support java.time formatters in SafeRouter handlers Jan 14, 2017
@danneu danneu changed the title Support java.time formatters in SafeRouter handlers Support java.time formatters in Router handlers Feb 4, 2017
@danneu danneu added the idea label Aug 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant