danneu / kog

🌶 A simple Kotlin web framework inspired by Clojure's Ring.
43 stars 4 forks source link

[Router] Add scope control #14

Closed danneu closed 7 years ago

danneu commented 7 years ago

A current source of end-user mistakes and kog-level bugs is that you can accidentally reference top-level methods when you're inside a nested builder block:

val router = Router {
    group("/prefix") {
        mount(otherRouter)
    }
}

In the above example, if RouteGroup didn't have the .mount() method, it'll call the top-level router .mount(otherRouter) which will mount the subrouter without a prefix.

To prevent these sorts of bugs in kog and for the end-user, kotlin 1.1 introduces dsl scope control (@DslMarker).