/// <summary> /// Handles an incoming <see cref="Request"/>. /// </summary> /// <param name="request">An <see cref="Request"/> instance, containing the information about the current request.</param> /// <returns>An <see cref="Response"/> instance containing the results of invoking the action that matched the <paramref name="request"/>.</returns> public Response HandleRequest(IRequest request) { if (request == null) { throw new ArgumentNullException("request", "The request parameter cannot be null."); } var modules = this.locator.GetModules(); if (modules.Any()) { var method = request.Method; if (method.ToUpperInvariant() == "HEAD") { method = "GET"; } if (modules.ContainsKey(method)) { var resolvedRoute = this.resolver.GetRoute(request, modules[method], application); var response = resolvedRoute.Invoke(); // TODO: REFACTOR if (request.Method.ToUpperInvariant() == "HEAD") { response = new HeadResponse(response); } return response; } } return new NotFoundResponse(); }
/// <summary> /// Handles an incoming <see cref="Request"/>. /// </summary> /// <param name="request">An <see cref="Request"/> instance, containing the information about the current request.</param> /// <returns>An <see cref="Response"/> instance containing the results of invoking the action that matched the <paramref name="request"/>.</returns> public Response HandleRequest(IRequest request) { if (request == null) { throw new ArgumentNullException("request", "The request parameter cannot be null."); } var modules = this.locator.GetModules(); if (modules.Any()) { InitializeModules(request, modules); var descriptions = GetRouteDescriptions(request, modules); if (descriptions.Any()) { var resolvedRoute = this.resolver.GetRoute(request, descriptions); var response = resolvedRoute.Invoke(); // TODO: REFACTOR if (request.Method.ToUpperInvariant() == "HEAD") { response = new HeadResponse(response); } return response; } } return new NotFoundResponse(); }
public Response HandleRequest(Request request) { if (request == null) { throw new ArgumentNullException("request", "The request parameter cannot be null."); } var resolvedRoute = this.resolver.Resolve(request, this.routeCache); var response = resolvedRoute.Invoke(); if (request.Method.ToUpperInvariant() == "HEAD") { response = new HeadResponse(response); } return response; }