public void AddHandlerDescriptor(string method, string pathTemplate, NathanRequestDelegate requestDelegate, DeferredEndPointConventionBuilder endPointConventionBuilder) { var prefixedPathTemplate = $"{BasePath}/{pathTemplate}"; var handlerDescriptor = new NathanHandlerDescriptor(method, prefixedPathTemplate, requestDelegate, endPointConventionBuilder, this); HandlerDescriptors.Add(handlerDescriptor.Key, handlerDescriptor); }
public NathanHandlerDescriptor(string method, string pathTemplate, NathanRequestDelegate requestDelegate, DeferredEndPointConventionBuilder endPointConventionBuilder, NathanModuleDescriptor parentModuleDescriptor) { Method = method; PathTemplate = pathTemplate; RequestDelegate = requestDelegate; EndPointConventionBuilder = endPointConventionBuilder; ParentModuleDescriptor = parentModuleDescriptor; }
public NathanRequestDelegate Build(NathanApplicationConfiguration nathanApplicationConfiguration) { ConfigurePipeline(nathanApplicationConfiguration); NathanRequestDelegate application = nathanContext => Task.CompletedTask; foreach (var middleware in _middlewares) { application = middleware(application); } return(application); }
public async Task Invoke(NathanRequestContext nathanRequestContext, NathanRequestDelegate next) { var httpContext = nathanRequestContext.HttpContext; var storedHandlerDescriptor = nathanRequestContext.HandlerDescriptor; var nathanModule = httpContext .RequestServices .GetRequiredService(storedHandlerDescriptor.ParentModuleDescriptor.ModuleType) as NathanModule; var nathanHandler = nathanModule .ModuleDescriptor .HandlerDescriptors .First(d => d.Key == storedHandlerDescriptor.Key) .Value .RequestDelegate; await nathanHandler(nathanRequestContext); }
public async Task Invoke(NathanRequestContext nathanRequestContext, NathanRequestDelegate next) { await next(nathanRequestContext); }
protected IEndpointConventionBuilder MapMethod(string method, string pathTemplate, NathanRequestDelegate handler) { var deferredEndPointConventionBuilder = new DeferredEndPointConventionBuilder(); ModuleDescriptor.AddHandlerDescriptor(method, pathTemplate, handler, deferredEndPointConventionBuilder); return(deferredEndPointConventionBuilder); }
protected IEndpointConventionBuilder Delete(string pathTemplate, NathanRequestDelegate handler) { return(MapMethod(HttpMethods.Delete, pathTemplate, handler)); }