Ejemplo n.º 1
0
        /// <summary>Maps the specified route template for a Firestorm REST API running within Web API.</summary>
        /// <returns>A reference to the mapped route.</returns>
        /// <param name="routes">A collection of routes for the application.</param>
        /// <param name="directory">The starting directory of the REST API.</param>
        /// <param name="configureAction">The Firestorm configuration.</param>
        public static IHttpRoute MapFirestorm(this HttpRouteCollection routes, string directory, Action <IFirestormServicesBuilder> configureAction)
        {
            var servicesBuilder = new DefaultServicesBuilder();

            configureAction(servicesBuilder);
            var serviceProvider = servicesBuilder.Build();

            var config = new FirestormConfiguration
            {
                EndpointServices     = serviceProvider.GetService <EndpointServices>(),
                StartResourceFactory = serviceProvider.GetService <IStartResourceFactory>(),
            };

            FirestormController.GlobalConfig = config;

            config.StartResourceFactory.Initialize();

            return(routes.MapHttpRoute(name: "Firestorm" + (directory != null ? "_" + directory : "Root"), routeTemplate: (directory != null ? directory + "/" : string.Empty) + "{*path}", defaults: new
            {
                controller = "Firestorm",
            }));
        }
Ejemplo n.º 2
0
 private FirestormController(FirestormConfiguration configuration)
 {
     _config = configuration;
 }