I'm coming from clojure/pedestal and something than I like is could extend the properties in a context object, context are a bit similar to middlewares and filter
intercep 1 int 2
--> context -----------> context --------> context ---> controller
request request request
user: "tom" user:"tom"
admin : true
the initial context includes the request and in every interceptor I add new data to the context, for instance check the session and get the user-details based in its cookies (int 1) or get if he's admin (inter 2)...when the data come to the controller it includes useful information
I know the static limitation but I think than maybe it's possible using shapeless..for instance, in my finatra controller I would like something like...
type SuperRequest = ......
maybe would need some implicit heres
get("/hi") { request: SuperRequest =>
info("hi")
"Hello!! " + request.myHlist.get("name")
}
I think than the benefit would be a better composition because object doesnt compose well
.filter(filter1) //without HList I'd need create a new SuperRequest here with the user name
.filter(filter2) //and here other new object with the admin details
could be it a good approach? do you know a better alternative for extends the object in a composable way...