Scala 值解码不是org.http4s.AuthedRequest的成员
我使用的是Scala 值解码不是org.http4s.AuthedRequest的成员,scala,http4s,http4s-circe,Scala,Http4s,Http4s Circe,我使用的是http4sversion 0.18,带有Circe,当我使用以下代码将json主体转换为AuthedService中的case类时,我得到的错误是value decode不是org.http4s.AuthedRequest的成员: //案例类定义 案例类UserUpdate(名称:String) 导入org.http4s.AuthedService 导入org.http4s.circe_ val updateUserService:AuthedService[字符串,F]= 授权服务
http4s
version 0.18,带有Circe,当我使用以下代码将json主体转换为AuthedService
中的case类时,我得到的错误是value decode不是org.http4s.AuthedRequest的成员:
//案例类定义
案例类UserUpdate(名称:String)
导入org.http4s.AuthedService
导入org.http4s.circe_
val updateUserService:AuthedService[字符串,F]=
授权服务{
case req@PATCH->Root/“mypath”as>
req.decode[UserUpdate]{UserUpdate=>
...
}
}
事实证明,正如指定的那样,AuthedService
在AuthedRequest
上运行,这相当于(用户,请求[F])
,因此需要做的是调用对AuthedRequest
部分的请求进行解码,请参见:
//案例类定义
案例类UserUpdate(名称:String)
导入org.http4s.AuthedService
导入org.http4s.circe_
val updateUserService:AuthedService[字符串,F]=
授权服务{
case authReq@PATCH->Root/“mypath”as>
authReq.req.decode[UserUpdate]{UserUpdate=>
...
}
}