private static void MapRoutes(RouteCollection routes) { // Route to create a new package routes.MapDelegate("CreatePackage", "api/v2/package", new { httpMethod = new HttpMethodConstraint("PUT") }, context => CreatePackageService().CreatePackage(context.HttpContext)); // Route to delete packages routes.MapDelegate("DeletePackage", "api/v2/package/{packageId}/{version}", new { httpMethod = new HttpMethodConstraint("DELETE") }, context => CreatePackageService().DeletePackage(context.HttpContext)); // Route to get packages routes.MapDelegate("DownloadPackage", "api/v2/package/{packageId}/{version}", new { httpMethod = new HttpMethodConstraint("GET") }, context => CreatePackageService().DownloadPackage(context.HttpContext)); #if DEBUG // The default route is http://{root}/nuget/Packages var factory = new DataServiceHostFactory(); var serviceRoute = new ServiceRoute("nuget", factory, typeof(Packages)); serviceRoute.Defaults = new RouteValueDictionary { { "serviceType", "odata" } }; serviceRoute.Constraints = new RouteValueDictionary { { "serviceType", "odata" } }; routes.Add("nuget", serviceRoute); #endif }
private static void MapRoutes(RouteCollection routes) { // The default route is http://{root}/nuget/Packages var factory = new DataServiceHostFactory(); var serviceRoute = new ServiceRoute("nuget", factory, typeof(Packages)); serviceRoute.Defaults = new RouteValueDictionary { { "serviceType", "odata" } }; serviceRoute.Constraints = new RouteValueDictionary { { "serviceType", "odata" } }; routes.Add("nuget", serviceRoute); }
private void RegisterRoutes() { DataServiceHostFactory factory = new DataServiceHostFactory(); string serverName = Utils.ExtractServerNameFromConnectionString(ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString); var databaseNames = MongoContext.GetDatabaseNames(serverName); foreach (var databaseName in databaseNames) { RouteTable.Routes.Add(new ServiceRoute(databaseName, factory, typeof(MongOData))); } }
public static void Start() { // The default route is http://{root}/nuget/Packages var factory = new DataServiceHostFactory(); var serviceRoute = new ServiceRoute("nuget", factory, typeof(Packages)); serviceRoute.Defaults = new RouteValueDictionary { { "serviceType", "odata" } }; serviceRoute.Constraints = new RouteValueDictionary { { "serviceType", "odata" } }; RouteTable.Routes.Add("nuget", serviceRoute); }
private static void MapRoutes(RouteCollection routes) { // Route to create a new package(http://{root}/nuget) routes.MapDelegate("CreatePackageNuGet", "nuget", new { httpMethod = new HttpMethodConstraint("PUT") }, context => CreatePackageService().CreatePackage(context.HttpContext)); // The default route is http://{root}/nuget/Packages var factory = new DataServiceHostFactory(); var serviceRoute = new ServiceRoute("nuget", factory, typeof(Packages)); serviceRoute.Defaults = new RouteValueDictionary { { "serviceType", "odata" } }; serviceRoute.Constraints = new RouteValueDictionary { { "serviceType", "odata" } }; routes.Add("nuget", serviceRoute); }
private static void MapRoutes(RouteCollection routes) { // The default route is http://{root}/nuget/Packages var factory = new DataServiceHostFactory(); var serviceRoute = new ServiceRoute("nuget", factory, typeof(Packages)); serviceRoute.Defaults = new RouteValueDictionary { { "serviceType", "odata" } }; serviceRoute.Constraints = new RouteValueDictionary { { "serviceType", "odata" } }; routes.Add("nuget", serviceRoute); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); // For some godforsaken reason, the PublishPackage route (registered by NuGet.Server) causes the { controller, action } => url mapping to always return this route. routes.Remove(routes.OfType<Route>().Single(r => r.DataTokens != null && r.DataTokens.ContainsKey("__RouteName") && (string)r.DataTokens["__RouteName"] == "PublishPackage")); }
protected void Application_Start(object sender, EventArgs e) { DataServiceHostFactory factory = new DataServiceHostFactory(); RouteTable.Routes.Add( new ServiceRoute("", factory, typeof(A5jsAPI))); }
private static void RegisterRoutes() { DataServiceHostFactory factory = new DataServiceHostFactory(); RouteTable.Routes.Add( new ServiceRoute(ODataValidator.ServiceName, factory, typeof(ODataValidator))); }