public RequestHandler(Request request, IHttpMethodImplementation httpMethodImplementation, ILoggerFactory loggerFactory, DoloresSettings settings) { _request = request; _httpMethodImplementation = httpMethodImplementation; _loggerFactory = loggerFactory; _logger = loggerFactory.CreateLogger <RequestHandler>(); _settings = settings; }
public static DoloresHandler CreateDoloresHandler(IHttpMethodImplementation methodImplementation, Request request, ILoggerFactory loggerFactory, DoloresSettings settings) { var assembly = LoadAssembly(methodImplementation.AssemblyName); var type = GetType(methodImplementation.FullyQualifiedClassName, assembly); var doloresHandler = CreateInstance(type); doloresHandler.Request = request; doloresHandler.Logger = loggerFactory.CreateLogger(type); doloresHandler.DoloresSettings = settings; doloresHandler.RouteHelper = new RouteHelper(settings); return(doloresHandler); }
public IHttpMethodImplementation FindImplementation(Request request, Route route) { IHttpMethodImplementation httpMethodImplementation = null; switch (request.Method) { case HttpMethod.Get: httpMethodImplementation = route.Implementations.SingleOrDefault(x => x.HttpMethod == HttpMethod.Get); break; case HttpMethod.Post: httpMethodImplementation = route.Implementations.SingleOrDefault(x => x.HttpMethod == HttpMethod.Post); break; case HttpMethod.Put: httpMethodImplementation = route.Implementations.SingleOrDefault(x => x.HttpMethod == HttpMethod.Put); break; case HttpMethod.Delete: httpMethodImplementation = route.Implementations.SingleOrDefault(x => x.HttpMethod == HttpMethod.Delete); break; case HttpMethod.Patch: httpMethodImplementation = route.Implementations.SingleOrDefault(x => x.HttpMethod == HttpMethod.Patch); break; case HttpMethod.Head: httpMethodImplementation = route.Implementations.SingleOrDefault(x => x.HttpMethod == HttpMethod.Head); break; case HttpMethod.Options: httpMethodImplementation = route.Implementations.SingleOrDefault(x => x.HttpMethod == HttpMethod.Options); break; } return(httpMethodImplementation); }