Ejemplo n.º 1
0
        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));
            });
        }
Ejemplo n.º 2
0
        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);
                }
            }
        }
Ejemplo n.º 3
0
        public static IApplicationBuilder UseNano(this IApplicationBuilder app, NanoConfiguration config = null)
        {
            Init(app, config);

            return(app);
        }