|
4 | 4 |
|
5 | 5 | namespace BaGet.Extensions
|
6 | 6 | {
|
7 |
| - public static class IRouteBuilderExtensions |
| 7 | + public static class IEndpointRouteBuilderExtensions |
8 | 8 | {
|
9 |
| - public static IRouteBuilder MapServiceIndexRoutes(this IRouteBuilder routes) |
| 9 | + public static void MapServiceIndexRoutes(this IEndpointRouteBuilder endpoints) |
10 | 10 | {
|
11 |
| - return routes.MapRoute( |
| 11 | + endpoints.MapControllerRoute( |
12 | 12 | name: Routes.IndexRouteName,
|
13 |
| - template: "v3/index.json", |
14 |
| - defaults: new { controller = "ServiceIndex", action = "GetAsync" }); |
| 13 | + pattern: "v3/index.json", |
| 14 | + defaults: new { controller = "ServiceIndex", action = "Get" }); |
15 | 15 | }
|
16 | 16 |
|
17 |
| - public static IRouteBuilder MapPackagePublishRoutes(this IRouteBuilder routes) |
| 17 | + public static void MapPackagePublishRoutes(this IEndpointRouteBuilder endpoints) |
18 | 18 | {
|
19 |
| - routes.MapRoute( |
| 19 | + endpoints.MapControllerRoute( |
20 | 20 | name: Routes.UploadPackageRouteName,
|
21 |
| - template: "api/v2/package", |
| 21 | + pattern: "api/v2/package", |
22 | 22 | defaults: new { controller = "PackagePublish", action = "Upload" },
|
23 | 23 | constraints: new { httpMethod = new HttpMethodRouteConstraint("PUT") });
|
24 | 24 |
|
25 |
| - routes.MapRoute( |
| 25 | + endpoints.MapControllerRoute( |
26 | 26 | name: Routes.DeleteRouteName,
|
27 |
| - template: "api/v2/package/{id}/{version}", |
| 27 | + pattern: "api/v2/package/{id}/{version}", |
28 | 28 | defaults: new { controller = "PackagePublish", action = "Delete" },
|
29 | 29 | constraints: new { httpMethod = new HttpMethodRouteConstraint("DELETE") });
|
30 | 30 |
|
31 |
| - routes.MapRoute( |
| 31 | + endpoints.MapControllerRoute( |
32 | 32 | name: Routes.RelistRouteName,
|
33 |
| - template: "api/v2/package/{id}/{version}", |
| 33 | + pattern: "api/v2/package/{id}/{version}", |
34 | 34 | defaults: new { controller = "PackagePublish", action = "Relist" },
|
35 | 35 | constraints: new { httpMethod = new HttpMethodRouteConstraint("POST") });
|
36 |
| - |
37 |
| - return routes; |
38 | 36 | }
|
39 | 37 |
|
40 |
| - public static IRouteBuilder MapSymbolRoutes(this IRouteBuilder routes) |
| 38 | + public static void MapSymbolRoutes(this IEndpointRouteBuilder endpoints) |
41 | 39 | {
|
42 |
| - routes.MapRoute( |
| 40 | + endpoints.MapControllerRoute( |
43 | 41 | name: Routes.UploadSymbolRouteName,
|
44 |
| - template: "api/v2/symbol", |
| 42 | + pattern: "api/v2/symbol", |
45 | 43 | defaults: new { controller = "Symbol", action = "Upload" },
|
46 | 44 | constraints: new { httpMethod = new HttpMethodRouteConstraint("PUT") });
|
47 | 45 |
|
48 |
| - routes.MapRoute( |
49 |
| - name: Routes.SymbolDownloadRouteName, |
50 |
| - template: "api/download/symbols/{file}/{key}/{file2}", |
51 |
| - defaults: new { controller = "Symbol", action = "Get" }); |
52 |
| - |
53 |
| - routes.MapRoute( |
| 46 | + endpoints.MapControllerRoute( |
54 | 47 | name: Routes.SymbolDownloadRouteName,
|
55 |
| - template: "api/download/symbols/{prefix}/{file}/{key}/{file2}", |
| 48 | + pattern: "api/download/symbols/{file}/{key}/{file2}", |
56 | 49 | defaults: new { controller = "Symbol", action = "Get" });
|
57 | 50 |
|
58 |
| - return routes; |
| 51 | + endpoints.MapControllerRoute( |
| 52 | + name: Routes.PrefixedSymbolDownloadRouteName, |
| 53 | + pattern: "api/download/symbols/{prefix}/{file}/{key}/{file2}", |
| 54 | + defaults: new { controller = "Symbol", action = "Get" }); |
59 | 55 | }
|
60 | 56 |
|
61 |
| - public static IRouteBuilder MapSearchRoutes(this IRouteBuilder routes) |
| 57 | + public static void MapSearchRoutes(this IEndpointRouteBuilder endpoints) |
62 | 58 | {
|
63 |
| - routes.MapRoute( |
| 59 | + endpoints.MapControllerRoute( |
64 | 60 | name: Routes.SearchRouteName,
|
65 |
| - template: "v3/search", |
66 |
| - defaults: new { controller = "Search", action = "SearchAsync" }); |
| 61 | + pattern: "v3/search", |
| 62 | + defaults: new { controller = "Search", action = "Search" }); |
67 | 63 |
|
68 |
| - routes.MapRoute( |
| 64 | + endpoints.MapControllerRoute( |
69 | 65 | name: Routes.AutocompleteRouteName,
|
70 |
| - template: "v3/autocomplete", |
71 |
| - defaults: new { controller = "Search", action = "AutocompleteAsync" }); |
| 66 | + pattern: "v3/autocomplete", |
| 67 | + defaults: new { controller = "Search", action = "Autocomplete" }); |
72 | 68 |
|
73 | 69 | // This is an unofficial API to find packages that depend on a given package.
|
74 |
| - routes.MapRoute( |
| 70 | + endpoints.MapControllerRoute( |
75 | 71 | name: Routes.DependentsRouteName,
|
76 |
| - template: "v3/dependents", |
77 |
| - defaults: new { controller = "Search", action = "DependentsAsync" }); |
78 |
| - |
79 |
| - return routes; |
| 72 | + pattern: "v3/dependents", |
| 73 | + defaults: new { controller = "Search", action = "Dependents" }); |
80 | 74 | }
|
81 | 75 |
|
82 |
| - public static IRouteBuilder MapPackageMetadataRoutes(this IRouteBuilder routes) |
| 76 | + public static void MapPackageMetadataRoutes(this IEndpointRouteBuilder endpoints) |
83 | 77 | {
|
84 |
| - routes.MapRoute( |
| 78 | + endpoints.MapControllerRoute( |
85 | 79 | name: Routes.RegistrationIndexRouteName,
|
86 |
| - template: "v3/registration/{id}/index.json", |
87 |
| - defaults: new { controller = "PackageMetadata", action = "RegistrationIndexAsync" }); |
| 80 | + pattern: "v3/registration/{id}/index.json", |
| 81 | + defaults: new { controller = "PackageMetadata", action = "RegistrationIndex" }); |
88 | 82 |
|
89 |
| - routes.MapRoute( |
| 83 | + endpoints.MapControllerRoute( |
90 | 84 | name: Routes.RegistrationLeafRouteName,
|
91 |
| - template: "v3/registration/{id}/{version}.json", |
92 |
| - defaults: new { controller = "PackageMetadata", action = "RegistrationLeafAsync" }); |
93 |
| - |
94 |
| - return routes; |
| 85 | + pattern: "v3/registration/{id}/{version}.json", |
| 86 | + defaults: new { controller = "PackageMetadata", action = "RegistrationLeaf" }); |
95 | 87 | }
|
96 | 88 |
|
97 |
| - public static IRouteBuilder MapPackageContentRoutes(this IRouteBuilder routes) |
| 89 | + public static void MapPackageContentRoutes(this IEndpointRouteBuilder endpoints) |
98 | 90 | {
|
99 |
| - routes.MapRoute( |
| 91 | + endpoints.MapControllerRoute( |
100 | 92 | name: Routes.PackageVersionsRouteName,
|
101 |
| - template: "v3/package/{id}/index.json", |
102 |
| - defaults: new { controller = "PackageContent", action = "GetPackageVersionsAsync" }); |
| 93 | + pattern: "v3/package/{id}/index.json", |
| 94 | + defaults: new { controller = "PackageContent", action = "GetPackageVersions" }); |
103 | 95 |
|
104 |
| - routes.MapRoute( |
| 96 | + endpoints.MapControllerRoute( |
105 | 97 | name: Routes.PackageDownloadRouteName,
|
106 |
| - template: "v3/package/{id}/{version}/{idVersion}.nupkg", |
107 |
| - defaults: new { controller = "PackageContent", action = "DownloadPackageAsync" }); |
| 98 | + pattern: "v3/package/{id}/{version}/{idVersion}.nupkg", |
| 99 | + defaults: new { controller = "PackageContent", action = "DownloadPackage" }); |
108 | 100 |
|
109 |
| - routes.MapRoute( |
| 101 | + endpoints.MapControllerRoute( |
110 | 102 | name: Routes.PackageDownloadManifestRouteName,
|
111 |
| - template: "v3/package/{id}/{version}/{id2}.nuspec", |
112 |
| - defaults: new { controller = "PackageContent", action = "DownloadNuspecAsync" }); |
| 103 | + pattern: "v3/package/{id}/{version}/{id2}.nuspec", |
| 104 | + defaults: new { controller = "PackageContent", action = "DownloadNuspec" }); |
113 | 105 |
|
114 |
| - routes.MapRoute( |
| 106 | + endpoints.MapControllerRoute( |
115 | 107 | name: Routes.PackageDownloadReadmeRouteName,
|
116 |
| - template: "v3/package/{id}/{version}/readme", |
117 |
| - defaults: new { controller = "PackageContent", action = "DownloadReadmeAsync" }); |
118 |
| - |
119 |
| - return routes; |
| 108 | + pattern: "v3/package/{id}/{version}/readme", |
| 109 | + defaults: new { controller = "PackageContent", action = "DownloadReadme" }); |
120 | 110 | }
|
121 | 111 | }
|
122 | 112 | }
|
0 commit comments