/*
* Copyright (c) Akveo 2019. All Rights Reserved.
* Licensed under the Personal / Commercial License.
* See LICENSE_PERSONAL / LICENSE_COMMERCIAL in the project root for license information on type of purchased license.
*/

using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;

namespace Common.WebApi
{
    public static class RouteConfig
    {
        public static void ConfigureRoutes(HttpConfiguration config)
        {
            config.Routes.Clear();

            RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            RouteTable.Routes.MapRoute(
                name: "Default",
                url: "",
                defaults: new { controller = "NgxApp", action = "Index" }
            );

            var baseEndpoint = "api";

            config.MapHttpAttributeRoutes(new CentralizedPrefixProvider(baseEndpoint));

            config.Routes.MapHttpRoute(
                name: "Api",
                routeTemplate: $"{baseEndpoint}/{{controller}}/{{id}}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
    }
}