private ResolveResult InvokeRouteResolver(Context context, string path, IEnumerable<Tuple<string, decimal>> acceptHeaders) { context.Request.Headers.Accept = acceptHeaders.ToList(); context.Request.Url.Path = path; return _routeResolver.Resolve(context); }
private ResolveResult Resolve(Context context) { var originalAcceptHeaders = context.Request.Headers.Accept; var originalRequestPath = context.Request.Path; return InvokeRouteResolver(context, originalRequestPath, originalAcceptHeaders); }
public async Task<Response> Dispatch(Context context, CancellationToken cancellationToken) { var resolveResult = Resolve(context); context.Parameters = resolveResult.Parameters; context.ResolvedRoute = resolveResult.Route; return await _routeInvoker.Invoke(resolveResult.Route, cancellationToken, resolveResult.Parameters, context); }
public Response GetContent(Context context) { foreach (var convention in this.conventions) { var result = convention.Invoke(context, this.rootPath); if (result != null) { return result; } } return null; }
public ResponseFormatter Create(Context context) { return new ResponseFormatter(context, this.serializers); }
public async Task<Context> HandleHttp(HttpListenerContext httpContext, Uri baseUri, CancellationToken cancellationToken) { if (httpContext == null) throw new ArgumentNullException("httpContext"); var request = ConvertRequest(baseUri, httpContext.Request); var context = new Context() { Request = request, }; var staticContentResponse = _staticContentProvider.GetContent(context); if (staticContentResponse != null) { context.Response = staticContentResponse; } else { context.Response = await _requestDispatcher.Dispatch(context, cancellationToken).ConfigureAwait(false); } ConvertResponse(context.Response, httpContext.Response); return context; }