Exemplo n.º 1
0
        public static void Configure(HttpConfiguration httpConfig, DexCMSConfiguration config)
        {
            JsonMediaTypeFormatter jsonFormatter = httpConfig.Formatters.JsonFormatter;
            List<string> supportedMediaTypes = config.RetrieveValue<List<string>>(CoreApiOptions.SupportedMediaTypes.ToString());
            if (supportedMediaTypes == null)
            {
                supportedMediaTypes = new List<string>
                {
                    "text/html"
                };
            }

            if (supportedMediaTypes != null)
            {
                foreach (var mediaType in supportedMediaTypes)
                {
                    jsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue(mediaType));
                }
            }
            if (!config.RetrieveValue<bool>(CoreApiOptions.IgnoreReferenceHandling.ToString()))
            {
                jsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            }
            if (!config.RetrieveValue<bool>(CoreApiOptions.UseCamelCase.ToString()))
            {
                jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            }
        }
Exemplo n.º 2
0
        public static void CreateDefaultRoutes(HttpConfiguration httpConfig, DexCMSConfiguration config)
        {
            string baseApi = config.RetrieveValue<string>(CoreApiOptions.CoreApiUrl.ToString());
            if (string.IsNullOrEmpty(baseApi))
            {
                baseApi = "api";
            }

            httpConfig.Routes.MapHttpRoute(
                name: "FileUpload",
                routeTemplate: baseApi + "/fileupload/upload",
                defaults: new { controller = "fileupload", action = "upload" }
            );

            httpConfig.Routes.MapHttpRoute(
                name: "RoleApi",
                routeTemplate: baseApi + "/roles/{id}",
                defaults: new { controller = "roles", id = RouteParameter.Optional }
            );

            httpConfig.Routes.MapHttpRoute(
                name: "UserApi",
                routeTemplate: baseApi + "/users/{id}",
                defaults: new { controller = "users", id = RouteParameter.Optional }
            );

            httpConfig.Routes.MapHttpRoute(
                name: "DefaultApiGetAll",
                routeTemplate: baseApi + "/{controller}"
            );

            httpConfig.Routes.MapHttpRoute(
                name: "CompositeApi",
                routeTemplate: baseApi + "/{controller}/{id}/{secondKey}",
                defaults: new { },
                constraints: new { id = @"^[0-9]+$", secondKey = @"^[0-9]+$" }
            );

            httpConfig.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: baseApi + "/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional },
                constraints: new { id = @"^[0-9]+$" }
            );

            httpConfig.Routes.MapHttpRoute(
                name: "DefaultApiByGroupID",
                routeTemplate: baseApi + "/{controller}/{bytype}/{id}",
                defaults: null,
                constraints: new { id = @"^[0-9]+$" }
            );
        }
Exemplo n.º 3
0
        public static void CreateDefaultRoutes(HttpConfiguration httpConfig, DexCMSConfiguration config)
        {
            string baseApi = config.RetrieveValue<string>(CoreApiOptions.CoreApiUrl.ToString());
            if (string.IsNullOrEmpty(baseApi))
            {
                baseApi = "api";
            }

            httpConfig.Routes.MapHttpRoute(
                name: "RetrieveContent",
                routeTemplate: baseApi + "/retrievecontents/{contentName}",
                defaults: new { controller = "retrievecontents" });
        }
Exemplo n.º 4
0
        public static void CreateDefaultRoutes(RouteCollection routes, DexCMSConfiguration config)
        {
            routes.MapRoute(
                "boom", "boom", new { controller = "PublicContent", action = "Boom" });

            routes.MapRoute(
                "sitemap", "sitemap.xml", new { controller = "Sitemap", action = "Index" });

            routes.MapRoute(
                name: "Contact",
                url: "contact",
                defaults: new { category = "none", controller = "Contact", action = "Index", urlSegment = "contact" }
            );

            routes.MapRoute(
                name: "ContactSuccess",
                url: "contact/success",
                defaults: new { category = "contact", controller = "Contact", action = "Success", urlSegment = "success" }
            );

            if (!config.RetrieveValue<bool>(BaseRouteOptions.DisableAccountRoutes.ToString()))
            {
                routes.MapRoute(
                    name: "Account",
                    url: "Account/{action}",
                    defaults: new { category = "account", controller = "Account" });

                routes.MapRoute(
                    name: "Manage",
                    url: "Manage",
                    defaults: new { category = "none", controller = "Manage", action = "Index", urlSegment = "manage" });

                routes.MapRoute(
                    name: "ManageActions",
                    url: "Manage/{action}",
                    defaults: new { category = "manage", controller = "Manage" });
            }

            //root page
            routes.MapRoute(
                name: "Default",
                url: "",
                defaults: new { urlSegment = "index", controller = "PublicContent", action = "Index" }
            );

            //THESE are the catch all routes that display dynamic content
            routes.MapRoute(
                name: "Content",
                url: "{urlSegment}",
                defaults: new { controller = "PublicContent", action = "RetrieveContent" }
            );

            routes.MapRoute(
                name: "ContentCategory",
                url: "{category}/{urlSegment}",
                defaults: new { controller = "PublicContent", action = "RetrieveContentByCategory" }
            );

            routes.MapRoute(
                name: "ContentSubCategory",
                url: "{category}/{subCategory}/{urlSegment}",
                defaults: new { controller = "PublicContent", action = "RetrieveContentBySubCategory" }
            );
        }