Daniel
04/24/2023, 10:11 AMget
(and others) have signature of PipelineContext<Unit, ApplicationCall>
. Where is the first type (Unit
) coming from and is this something I can change by dsl function to be for example some API context data class that is common for a group of routes?Aleksei Tirman [JB]
04/24/2023, 11:26 AMDaniel
04/24/2023, 11:33 AMroute("/api/v1"){
// parse important data common to all api requests and save them as subject
route("/endpoint1") {
head {
val ctx = subject
//do sth with ctx
}
get {
val ctx = subject
//do sth with ctx
}
}
get("/endpoint2") {
val ctx = subject
//do sth with ctx
}
}
Aleksei Tirman [JB]
04/24/2023, 11:34 AMDaniel
04/24/2023, 12:01 PMAleksei Tirman [JB]
04/24/2023, 5:17 PMrouting {
val ctx = Object()
route("/endpoint1") {
head {
//do sth with ctx
}
get {
//do sth with ctx
}
}
get("/endpoint2") {
//do sth with ctx
}
}
Daniel
04/25/2023, 10:44 AMObject
in your snippet), which is not possible since the receiver of the route
function doesn't have access to those (afaik)