Scala 在请求对象欺骗服务中,Shapeless可以作为扩展属性的良好资源吗

Scala 在请求对象欺骗服务中,Shapeless可以作为扩展属性的良好资源吗,scala,shapeless,Scala,Shapeless,我来自clojure/Destale,我不喜欢的东西是可以扩展上下文对象中的属性,上下文有点类似于中间件和过滤器 intercep 1 int 2 --> context -----------> context --------> context ---> controller request request request

我来自clojure/Destale,我不喜欢的东西是可以扩展上下文对象中的属性,上下文有点类似于中间件和过滤器

            intercep 1           int 2
--> context -----------> context --------> context  ---> controller
     request              request           request
                          user: "tom"       user:"tom"  
                                            admin : true
初始上下文包括请求和 在每个拦截器中,我向上下文添加新数据,例如检查会话并根据其cookies(int 1)获取用户详细信息,或者获取他是否是管理员(inter 2)…当数据到达控制器时,它包含有用的信息

我知道静态限制,但我认为使用shapeless是可能的。例如,在我的finatra控制器中,我想要一些像

type SuperRequest = ......
maybe would need some implicit heres

get("/hi") { request: SuperRequest =>

info("hi")
"Hello!!  " + request.myHlist.get("name")
}

我认为这样做的好处是更好的组合,因为对象组合不好

   .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
这是一个好办法吗?你知道一个更好的方法来以可组合的方式扩展对象吗