Ejemplo n.º 1
0
        public void RegisterEndpoints(IEndpointRouteBuilder builder)
        {
            // called e.g in Startup.Configure(app, env) ... app.UseEndpoints(builder  => {  broker.RegisterEndpoints(builder); })

            if (fallbackDelegate != null)
            {
                var cbuilder = builder.MapFallback(fallbackDelegate);
                ConfigureFallback(cbuilder);
            }

            foreach (IEndpointRegistration reg in endpoints)
            {
                string          path   = reg.RoutingTemplate;
                RequestDelegate delg   = reg.EndpointDelegate;
                RequestMethod   method = reg.EndpointMethods;

                if (method.HasFlag(RequestMethod.Get))
                {
                    var cbuilder = builder.MapGet(path, delg);
                    reg.ConfigureEndpoint(RequestMethod.Get, cbuilder);
                }
                if (method.HasFlag(RequestMethod.Post))
                {
                    var cbuilder = builder.MapPost(path, delg);
                    reg.ConfigureEndpoint(RequestMethod.Post, cbuilder);
                }
                if (method.HasFlag(RequestMethod.Put))
                {
                    var cbuilder = builder.MapPut(path, delg);
                    reg.ConfigureEndpoint(RequestMethod.Put, cbuilder);
                }
                if (method.HasFlag(RequestMethod.Delete))
                {
                    var cbuilder = builder.MapDelete(path, delg);
                    reg.ConfigureEndpoint(RequestMethod.Delete, cbuilder);
                }
            }
        }