/// <summary> /// Initializes a new instance of the <see cref="ScrambleServerGenerator"/> class. /// </summary> public ScrambleServerGenerator( IHttpClientFactory httpClientFactory, IHttpResponseHandler httpResponseHandler) { _httpClientFactory = httpClientFactory; _httpResponseHandler = httpResponseHandler; }
/// <summary> /// Initializes a new instance of the <see cref="IRegisterRepository"/> class. /// </summary> public RegisterServerRepository( IHttpClientFactory httpClientFactory, IHttpResponseHandler httpResponseHandler) { _httpClientFactory = httpClientFactory; _httpResponseHandler = httpResponseHandler; }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="handler"></param> public void SetHandler <T>(IHttpResponseHandler handler) where T : Link, new() { var t = new T(); var reg = _LinkRegistry[t.Relation]; reg.ResponseHandler = handler; }
public RoomServerService( IHttpClientFactory httpClientFactory, IHttpResponseHandler httpResponseHandler) { _httpClientFactory = httpClientFactory; _httpResponseHandler = httpResponseHandler; _subject = new Subject <RoomNotification>(); }
private IHttpResponseHandler GetHttpResponseHandler(HttpFunctionDefinition httpFunctionDefinition) { IHttpResponseHandler httpResponseHandler = httpFunctionDefinition.HasHttpResponseHandler ? (IHttpResponseHandler)ServiceProvider.GetRequiredService(httpFunctionDefinition.HttpResponseHandlerType) : new DefaultHttpResponseHandler(); return(httpResponseHandler); }
public ResponderMiddleware(RequestDelegate nextStep, IHttpStatusCodeHandler httpStatusCodeHandler, IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor) { _nextStep = nextStep; _httpContextAccessor = httpContextAccessor; _httpStatusCodeHandler = httpStatusCodeHandler; _httpResponseHandler = new HttpResponseHandler(); }
/// <summary> /// Initializes a new instance of the <see cref="SessionsServerRepository"/> class. /// </summary> public SessionsServerRepository( IHttpClientFactory httpClientFactory, IUserClient userClient, IHttpResponseHandler httpResponseHandler) { _httpClientFactory = httpClientFactory; _userClient = userClient; _httpResponseHandler = httpResponseHandler; }
/// <summary> /// Runs a command through the IActionResult ASP.Net pathways and returns a HTTP response. /// This is useful for testing end to end HTTP triggered functions without having to actually host the /// function app. /// A method only needs specifying in the function supports multiple methods. /// </summary> public async Task <HttpResponse> ExecuteHttpAsync <TResult>(ICommand <TResult> command, HttpMethod method = null) { HttpFunctionDefinition httpFunctionDefinition = FindHttpFunctionDefinition(command); ActionContext actionContext = _aspNetRuntime.PrepareToExecuteHttp(command, httpFunctionDefinition, method); IHttpResponseHandler httpResponseHandler = GetHttpResponseHandler(httpFunctionDefinition); HttpDispatcher httpDispatcher = new HttpDispatcher(Dispatcher, ServiceProvider); IActionResult actionResult = await httpDispatcher.DispatchAndConvertToActionResult(command, httpResponseHandler, httpFunctionDefinition); return(await _aspNetRuntime.CreateHttpResponse(actionContext, actionResult)); }
public HttpApiEndpoint( HttpUrlDescriptor url, HttpMethod method, Dictionary<string, IHttpArgumentHandler> argumentHandlers, IHttpResponseHandler responseHandler, IEnumerable<HttpHeader> headers) { Url = url; Method = method; ArgumentHandlers = argumentHandlers; ResponseHandler = responseHandler; Headers = headers.ToList(); }
public HttpApiEndpoint( MethodInfo method, HttpUrlDescriptor url, HttpMethod httpMethod, Dictionary <string, IHttpArgumentHandler> argumentHandlers, IHttpResponseHandler responseHandler, IEnumerable <HttpHeader> headers, bool isAsync = true) { Method = method; Url = url; HttpMethod = httpMethod; ArgumentHandlers = argumentHandlers; ResponseHandler = responseHandler; Headers = headers.ToList(); }
public async Task <IActionResult> DispatchAndConvertToActionResult <TResult>( ICommand <TResult> command, IHttpResponseHandler httpResponseHandler, HttpFunctionDefinition httpFunctionDefinition) { IActionResult actionResult = null; try { TResult result = await _dispatcher.DispatchAsync(command); // TODO: Handle validation here Task <IActionResult> responseHandlerTask = httpResponseHandler.CreateResponse(command, result); if (responseHandlerTask != null) { actionResult = await responseHandlerTask; } if (actionResult == null) { actionResult = CreateResponse(200, result, httpFunctionDefinition); } } catch (ValidationException vex) { actionResult = await CreateValidationResponse(command, vex.ValidationResult, httpFunctionDefinition, httpResponseHandler); } catch (Exception ex) { Task exceptionResponseHandlerTask = httpResponseHandler.CreateResponseFromException(command, ex); if (exceptionResponseHandlerTask != null) { actionResult = await httpResponseHandler.CreateResponseFromException(command, ex); } if (actionResult == null) { actionResult = CreateResponse(500, "Unexpected error", httpFunctionDefinition); } } return(actionResult); }
public HttpResponseParser(IHttpResponseHandler handler) { _handler = handler; _parseBuffer = new byte[64*1024]; }
public IHttpRequest OnBadRequest <T>(Action <T, HttpStatusCode, string> action) { BadRequestResponseHandler = new BadRequestHttpResponseHandler <T>(action); return(this); }
public HttpResponseParser(IHttpResponseHandler handler) { this.handler = handler; this.parseBuffer = new byte[64 * 1024]; }
public IHttpRequest Always <T>(Action <T, HttpStatusCode> action) { UnconditionalResponseHandler = new UnconditionalHttpResponseHandler <T>(action); return(this); }
public HttpResponseParser(IHttpResponseHandler handler) { _handler = handler; _parseBuffer = new byte[64 * 1024]; }
private async Task <IActionResult> CreateValidationResponse(ICommand command, ValidationResult validationResult, HttpFunctionDefinition httpFunctionDefinition, IHttpResponseHandler responseHandler) { IActionResult actionResult = null; Task <IActionResult> validationResponseHandlerTask = responseHandler.CreateValidationFailureResponse(command, validationResult); if (validationResponseHandlerTask != null) { actionResult = await validationResponseHandlerTask; } return(actionResult ?? (CreateResponse(400, validationResult, httpFunctionDefinition))); }
public IHttpRequest OnOK <T>(Action <T> action) { OkResponseHandler = new OkHttpResponseHandler <T>(action); return(this); }