@@ -6,11 +6,19 @@ sealed trait Endpoint[F[_]] {
6
6
7
7
object Endpoint {
8
8
9
- def apply [F [_]](method : String ): PartiallyAppliedEndpoint [F ] = new PartiallyAppliedEndpoint [F ](method)
9
+ type MethodPattern = String
10
+ type Method = String
10
11
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 ) {
12
15
def apply [In , Err , Out ](
13
16
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 ]]
14
22
)(implicit inCodec : Codec [In ], errCodec : ErrorCodec [Err ], outCodec : Codec [Out ]): Endpoint [F ] =
15
23
RequestResponseEndpoint (method, run, inCodec, errCodec, outCodec)
16
24
@@ -25,16 +33,19 @@ object Endpoint {
25
33
)
26
34
27
35
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 ] =
28
39
NotificationEndpoint (method, run, inCodec)
29
40
30
41
}
31
42
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 ])
33
44
extends Endpoint [F ]
34
45
35
46
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 ]],
38
49
inCodec : Codec [In ],
39
50
errCodec : ErrorCodec [Err ],
40
51
outCodec : Codec [Out ]
0 commit comments