public async Task LocationController_GetWithValidWoeId_ReturnsValidLocationAsync(ILogger <LocationController> logger, ApiOptions apiOptions, IApiProxy apiProxy) { var expectedCount = 1; _apiProxy = apiProxy; // Arrange _apiProxy = Substitute.For <IApiProxy>(); _locationResponseBuilder = new TestLocationResponseBuilder(); _locationController = new LocationController(logger, apiOptions, _apiProxy); _apiProxy.SubmitLocationRequest(Arg.Any <ILocationRequest>()) .Returns(_locationResponseBuilder.Default().WithBelfast().Build()); // Act var locationResponse = await _locationController.Post(new LocationRequest()).ConfigureAwait(false); // Assert using (new AssertionScope()) { locationResponse.Should().BeOkObjectResult().ValueAs <ILocationResponse>().Locations .Should() .HaveCount(expectedCount); } }
public WeatherController(ILogger <WeatherController> logger, ApiOptions apiOptions, IApiProxy apiProxy) { _logger = logger; _apiOptions = apiOptions ?? throw new ArgumentNullException(nameof(apiOptions)); _apiProxy = apiProxy; }
public Uri ResolveOutboundUri(HttpContext context, IApiProxy apiProxy) { var pathWithNoInboundPathBase = context.Request.Path.Value.Replace(apiProxy.Options.InboundPathBase, "/"); var path = new PathString(pathWithNoInboundPathBase); var url = UriHelper.BuildAbsolute(apiProxy.Options.Scheme, apiProxy.Options.Host, apiProxy.Options.OutboundPathBase, path, context.Request.QueryString); url = QueryHelpers.AddQueryString(url, _apiProxyContextService.Get(context).Request.AppendQueryStringToApiRequest); return(new Uri(url)); }
public static void UseApiProxyRequestCaching(this IApplicationBuilder app, IApiProxy apiProxy) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (apiProxy == null) { throw new ArgumentNullException(nameof(apiProxy)); } app.UseMiddleware <ApiProxyRequestCachingMiddleware>(apiProxy); }
public ApiProxyRequestAuthenticationMiddleware(RequestDelegate next, IApiProxy apiProxy) { if (apiProxy == null) { throw new ArgumentNullException(nameof(apiProxy)); } if (string.IsNullOrWhiteSpace(apiProxy.Identifier)) { throw new ArgumentException("Api proxy must specify identifier.", nameof(apiProxy.Identifier)); } _next = next; _apiProxy = apiProxy; }
static public void RegisterChtSwaggerDoc <TService>(this IApiProxy <TService> it, bool useApiGateway) where TService : class { //Ordering/api/v1/HelloWorld var host = $"{it.ApiEndpoint.Scheme}://{it.ApiEndpoint.Host}:{it.ApiEndpoint.Port}"; var swaggerPath = useApiGateway ? string.Format(SwaggerExt.TakeSwaggerPathTemplate <TService>(), it.ApiVersion) : string.Format(SwaggerExt.SwaggerPathTemplate, it.ApiVersion); var swaggerEndpoint = new Uri($"{host}{swaggerPath}"); it.RegisterSwaggerDoc(swaggerEndpoint); //if (useApiGateway) //{ // it.ApiEndpoint = new Uri($"{host}/{SwaggerExt.ResolveServiceName<TService>()}/api/v{it.ApiVersion}"); //} }
public ApiProxyRequestMiddleware(RequestDelegate next, IApiProxy apiProxy) { if (apiProxy == null) { throw new ArgumentNullException(nameof(apiProxy)); } if (string.IsNullOrWhiteSpace(apiProxy.Options.Scheme)) { throw new ArgumentException("Api proxy options must specify scheme.", nameof(apiProxy.Options)); } if (!apiProxy.Options.Host.HasValue) { throw new ArgumentException("Api proxy options must specify host.", nameof(apiProxy.Options)); } _apiProxy = apiProxy; }
private void CallApi(IApiProxy <IHelloWorldService> proxy) { IHelloWorldService helloSvc = proxy.Svc; string id1 = "*abc*"; int id2 = 99; DateTime id3 = DateTime.Today; var id4 = new HelloInput() { UserName = "******", Date = DateTime.Today }; var rlt = helloSvc.Hello(id1, id2, id3, id4); print($"API={nameof(IHelloWorldService.Hello)} User={rlt.UserName}\nDate={rlt.Date}\n{rlt.Summary}"); var postrlt = helloSvc.HelloPost("CCC", "DDD"); print($"API={nameof(IHelloWorldService.HelloPost)} result={postrlt}"); var getrlt = proxy.Svc.HelloGet("EEE", "FFF"); print($"API={nameof(IHelloWorldService.HelloGet)} result={getrlt}"); }
protected ClientBase(IApiProxy apiProxy) { ApiProxy = apiProxy; }
public EmploymentsController(IApiProxy proxy) { _proxy = proxy; }
public BaseController(IApiProxy proxy) { this.Proxy = proxy; }
public InfuraApiService(IApiProxy apiProxy, ILogger <InfuraApiService> logger) { _apiProxy = apiProxy; _logger = logger; }
public ApiRequestHandler() { apiProxy = new ApiProxy(); }
public Functions(IApiProxy apiProxy) { _apiProxy = apiProxy; }
public CotizacionesController(IConfiguration Configuration, IApiProxy proxy) : base(proxy) { this._config = Configuration; this.Proxy = proxy; }
public HomeController(IApiProxy apiProxy) { _apiProxy = apiProxy; _apiProxy.RegisterAsDummyUserAndUseBearerToken(); }
public GenericController(IApiProxy apiProxy) { _apiProxy = apiProxy; }
public RecibosController(IConfiguration Configuration, IApiProxy proxy) : base(proxy) { this._config = Configuration; this.Proxy = proxy; }
public ApiProxyResponseMiddleware(RequestDelegate next, IApiProxy apiProxy) { _apiProxy = apiProxy; _next = next; }
public ProductosController(IConfiguration config, IApiProxy proxy) : base(proxy) { _config = config; Proxy = proxy; }
public UsuarioProxy(IApiProxy apiProxy) : base(apiProxy) { }
public ProveedoresController(IConfiguration Configuration, IApiProxy proxy) : base(proxy) { this._config = Configuration; this.Proxy = proxy; }
public PersonsController(IApiProxy proxy) { _proxy = proxy; }
public static void UseApiProxyResponseInterceptor(this IApplicationBuilder app, IApiProxy apiProxy) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (apiProxy == null) { throw new ArgumentNullException(nameof(apiProxy)); } app.UseMiddleware <ApiProxyResponseInterceptorMiddleware>(apiProxy); }