scala - How to use cookie and BASIC authentication together? -
i using combination of cookie , basic authentication. in basic authentication, takes function
option[userpass] => future[option[t]] and returns directive[t].
i wish create directive on cookie takes function
httpcookie => future[t] and returns directive[t].
hence can combined auth directive of cookieauth | basicauth.
the closest is:
def myfunction:httpcookie => future[string] val cookieauth:directive[string] = cookie("mycookie").flatmap { cookie => onsuccess(myfunction(cookie)) } but signatures not match. exception:
type mismatch; found : spray.routing.directive[shapeless.::[string,shapeless.hnil]] required: spray.routing.directive[string] ^
tl;dr make result of type directive1[string].
the initial problem in type mismatch. pure directive trait takes type parameter upper bound of hlist result type based on shapeless's hlist directive[string :: hnil].
in routing package object declared type alises directive[hnil] , directive[t :: hnil], directive0 , directive1[t], respectively.
Comments
Post a Comment