@@ -6,11 +6,19 @@ sealed trait Endpoint[F[_]] {
66
77object Endpoint {
88
9- def apply [F [_]](method : String ): PartiallyAppliedEndpoint [F ] = new PartiallyAppliedEndpoint [F ](method)
9+ type MethodPattern = String
10+ type Method = String
1011
11- class PartiallyAppliedEndpoint [F [_]](method : String ) {
12+ def apply [F [_]](method : Method ): PartiallyAppliedEndpoint [F ] = new PartiallyAppliedEndpoint [F ](method)
13+
14+ class PartiallyAppliedEndpoint [F [_]](method : MethodPattern ) {
1215 def apply [In , Err , Out ](
1316 run : In => F [Either [Err , Out ]]
17+ )(implicit inCodec : Codec [In ], errCodec : ErrorCodec [Err ], outCodec : Codec [Out ]): Endpoint [F ] =
18+ RequestResponseEndpoint (method, (_ : Method , in) => run(in), inCodec, errCodec, outCodec)
19+
20+ def full [In , Err , Out ](
21+ run : (Method , In ) => F [Either [Err , Out ]]
1422 )(implicit inCodec : Codec [In ], errCodec : ErrorCodec [Err ], outCodec : Codec [Out ]): Endpoint [F ] =
1523 RequestResponseEndpoint (method, run, inCodec, errCodec, outCodec)
1624
@@ -25,16 +33,19 @@ object Endpoint {
2533 )
2634
2735 def notification [In ](run : In => F [Unit ])(implicit inCodec : Codec [In ]): Endpoint [F ] =
36+ NotificationEndpoint (method, (_ : Method , in) => run(in), inCodec)
37+
38+ def notificationFull [In ](run : (Method , In ) => F [Unit ])(implicit inCodec : Codec [In ]): Endpoint [F ] =
2839 NotificationEndpoint (method, run, inCodec)
2940
3041 }
3142
32- final case class NotificationEndpoint [F [_], In ](method : String , run : In => F [Unit ], inCodec : Codec [In ])
43+ final case class NotificationEndpoint [F [_], In ](method : Method , run : ( Method , In ) => F [Unit ], inCodec : Codec [In ])
3344 extends Endpoint [F ]
3445
3546 final case class RequestResponseEndpoint [F [_], In , Err , Out ](
36- method : String ,
37- run : In => F [Either [Err , Out ]],
47+ method : Method ,
48+ run : ( Method , In ) => F [Either [Err , Out ]],
3849 inCodec : Codec [In ],
3950 errCodec : ErrorCodec [Err ],
4051 outCodec : Codec [Out ]
0 commit comments