private static void Init(IApplicationBuilder app, NanoConfiguration config) { Registrar.ConfigureRouter(config); app.Run(async(context) => { var routerResponse = await Router.Route(context); await context.Response.WriteAsync((string)JsonConvert.SerializeObject(routerResponse)); }); }
public static void ConfigureRouter(NanoConfiguration config) { foreach (var x in config.Controllers) { var controllerpath = x.Name; //Serving only public, static methods foreach (var y in x.GetMethods().Where(m => m.IsStatic && m.IsPublic)) { var methodpath = y.Name; var routepath = $"/{controllerpath}/{methodpath}"; var nanoMethod = new NanoMethod(y); Router.AddRoute(routepath, nanoMethod); } } }
public static IApplicationBuilder UseNano(this IApplicationBuilder app, NanoConfiguration config = null) { Init(app, config); return(app); }