@@ -17,6 +17,7 @@ public class ServiceChannel(
1717 public async Task < Result < TResponse > > SendAsync < TRequest , TResponse > (
1818 TRequest req ,
1919 CancellationToken ct ,
20+ string ? endpointUriPrefix = null ,
2021 MediaTypeHeaderValue ? mediaType = null ,
2122 JsonSerializerOptions ? jsonSerializerOptions = null ,
2223 Action < HttpRequestHeaders > ? configureRequestHeaders = null ,
@@ -39,7 +40,9 @@ public async Task<Result<TResponse>> SendAsync<TRequest, TResponse>(
3940 {
4041 return Result < TResponse > . CriticalError ( string . Format ( NoChannelRegistrationFound , typeof ( TRequest ) ) ) ;
4142 }
42- using ( HttpRequestMessage httpReq = new ( HttpMethod . Post , requestUriResult . Value ) )
43+ using ( HttpRequestMessage httpReq = new (
44+ HttpMethod . Post ,
45+ ServiceChannel . Combine ( endpointUriPrefix , requestUriResult . Value ) ) )
4346 {
4447 httpReq . Content = JsonContent . Create ( req , mediaType , jsonSerializerOptions ) ;
4548 configureRequestHeaders ? . Invoke ( httpReq . Headers ) ;
@@ -60,6 +63,7 @@ public async Task<Result<TResponse>> SendAsync<TRequest, TResponse>(
6063 public async Task < Result > SendAsync < TRequest > (
6164 TRequest req ,
6265 CancellationToken ct ,
66+ string ? endpointUriPrefix = null ,
6367 MediaTypeHeaderValue ? mediaType = null ,
6468 JsonSerializerOptions ? jsonSerializerOptions = null ,
6569 Action < HttpRequestHeaders > ? configureRequestHeaders = null ,
@@ -81,7 +85,9 @@ public async Task<Result> SendAsync<TRequest>(
8185 {
8286 return Result . CriticalError ( string . Format ( NoChannelRegistrationFound , typeof ( TRequest ) ) ) ;
8387 }
84- using ( HttpRequestMessage httpReq = new ( HttpMethod . Post , requestUriResult . Value ) )
88+ using ( HttpRequestMessage httpReq = new (
89+ HttpMethod . Post ,
90+ ServiceChannel . Combine ( endpointUriPrefix , requestUriResult . Value ) ) )
8591 {
8692 httpReq . Content = JsonContent . Create ( req , mediaType , jsonSerializerOptions ) ;
8793 configureRequestHeaders ? . Invoke ( httpReq . Headers ) ;
@@ -98,4 +104,16 @@ public async Task<Result> SendAsync<TRequest>(
98104 return ex ;
99105 }
100106 }
107+
108+ private static string Combine ( string ? endpointUriPrefix , string endpointUri )
109+ {
110+ if ( string . IsNullOrWhiteSpace ( endpointUriPrefix ) )
111+ {
112+ return endpointUri ;
113+ }
114+ return string . Format (
115+ "{0}/{1}" ,
116+ endpointUriPrefix . TrimEnd ( '/' ) ,
117+ endpointUri . TrimStart ( '/' ) ) ;
118+ }
101119}
0 commit comments