Esempio n. 1
0
        /// <summary>
        ///     Configures the application
        /// </summary>
        /// <param name="app">The app builder</param>
        public void Configuration(IAppBuilder app)
        {
            var configuration = new HttpConfiguration();

            ApiRouteConfig.Register(configuration);
            FormattersConfig.Register(configuration);

            app.UseWebApi(configuration);
        }
Esempio n. 2
0
 public Response <ApiRoute> GetNextStepRoute(string currentPath, ApiRouteConfig apiRouteConfig)
 {
     try {
         var requestUri  = new Uri(currentPath);
         var serviceName = UriHelper.GetServiceName(requestUri);
         var route       = apiRouteConfig.ApiRouteList.FirstOrDefault(a => a.ServiceName.ToLower() == serviceName.ToLower());
         if (route == null)
         {
             throw new InvalidRequestRouteException("无效路由请求");
         }
         return(new OkResponse <ApiRoute>(route));
     }
     catch (Exception e) {
         return(new ErrorResponse <ApiRoute>(new UnmappableRequestError(e)));
     }
 }
Esempio n. 3
0
        /// <summary>
        ///     Configures the application
        /// </summary>
        /// <param name="app">The app builder</param>
        /// <param name="serviceFacade">An instance of the service facade ofr mocking unit tests</param>
        public void Configuration(IAppBuilder app, IServiceFacade serviceFacade)
        {
            var config = new HttpConfiguration();

            ApiRouteConfig.Register(config);
            FormattersConfig.Register(config);
            MapperConfig.Initialize();
            DocumentationConfig.Register(config);

            // authorize all requests
            config.Filters.Add(new AuthorizeAttribute());

            // ioc container
            ContainerConfig.Register(app, config, serviceFacade);

            // cors
            app.UseCors(CorsOptions.AllowAll);
        }
 public static void Register(HttpConfiguration config)
 {
     ApiFilterConfig.Register(config);
     ApiProviderConfig.Register(config);
     ApiRouteConfig.Register(config);
 }