The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Routes.cs 38KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844
  1. using Microsoft.AspNetCore.Routing;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using Teknik.Configuration;
  7. using Teknik.Utilities;
  8. namespace Teknik
  9. {
  10. public static class Routes
  11. {
  12. public static void BuildRoutes(this IRouteBuilder routes, Config config)
  13. {
  14. routes.BuildDefaultRoutes(config);
  15. routes.BuildAboutRoutes(config);
  16. routes.BuildAbuseRoutes(config);
  17. routes.BuildAdminRoutes(config);
  18. routes.BuildAPIRoutes(config);
  19. routes.BuildBlogRoutes(config);
  20. routes.BuildContactRoutes(config);
  21. routes.BuildDevRoutes(config);
  22. routes.BuildErrorRoutes(config);
  23. routes.BuildFAQRoutes(config);
  24. routes.BuildHelpRoutes(config);
  25. routes.BuildHomeRoutes(config);
  26. routes.BuildPasteRoutes(config);
  27. routes.BuildPodcastRoutes(config);
  28. routes.BuildPrivacyRoutes(config);
  29. routes.BuildRSSRoutes(config);
  30. routes.BuildShortenerRoutes(config);
  31. routes.BuildStatsRoutes(config);
  32. routes.BuildTOSRoutes(config);
  33. routes.BuildUploadRoutes(config);
  34. routes.BuildUserRoutes(config);
  35. routes.BuildVaultRoutes(config);
  36. }
  37. public static void BuildDefaultRoutes(this IRouteBuilder routes, Config config)
  38. {
  39. routes.MapSubdomainRoute(
  40. name: "Default.Favicon",
  41. domains: new List<string>() { config.Host, config.ShortenerConfig.ShortenerHost },
  42. subDomains: new List<string>() { "*" },
  43. template: "favicon.ico",
  44. defaults: new { area = "Default", controller = "Default", action = "Favicon" }
  45. );
  46. routes.MapSubdomainRoute(
  47. name: "Default.Logo",
  48. domains: new List<string>() { config.Host, config.ShortenerConfig.ShortenerHost },
  49. subDomains: new List<string>() { "*" },
  50. template: "logo.svg",
  51. defaults: new { area = "Default", controller = "Default", action = "Logo" }
  52. );
  53. routes.MapSubdomainRoute(
  54. name: "Default.Robots",
  55. domains: new List<string>() { config.Host, config.ShortenerConfig.ShortenerHost },
  56. subDomains: new List<string>() { "*" },
  57. template: "robots.txt",
  58. defaults: new { area = "Default", controller = "Default", action = "Robots" }
  59. );
  60. routes.MapSubdomainRoute(
  61. name: "Default.NotFound",
  62. domains: new List<string>() { config.Host, config.ShortenerConfig.ShortenerHost },
  63. subDomains: new List<string>() { "*" },
  64. template: "{url}",
  65. defaults: new { area = "Error", controller = "Error", action = "Http404" },
  66. constraints: new { url = "{*url}" }
  67. );
  68. }
  69. public static void BuildAboutRoutes(this IRouteBuilder routes, Config config)
  70. {
  71. routes.MapSubdomainRoute(
  72. name: "About.Index",
  73. domains: new List<string>() { config.Host },
  74. subDomains: new List<string>() { "about" },
  75. template: "",
  76. defaults: new { area = "About", controller = "About", action = "Index" }
  77. );
  78. }
  79. public static void BuildAbuseRoutes(this IRouteBuilder routes, Config config)
  80. {
  81. routes.MapSubdomainRoute(
  82. name: "Abuse.Index",
  83. domains: new List<string>() { config.Host },
  84. subDomains: new List<string>() { "abuse" },
  85. template: "",
  86. defaults: new { area = "Abuse", controller = "Abuse", action = "Index" }
  87. );
  88. }
  89. public static void BuildAdminRoutes(this IRouteBuilder routes, Config config)
  90. {
  91. routes.MapSubdomainRoute(
  92. name: "Admin.Dashboard",
  93. domains: new List<string>() { config.Host },
  94. subDomains: new List<string>() { "admin" },
  95. template: "",
  96. defaults: new { area = "Admin", controller = "Admin", action = "Dashboard" }
  97. );
  98. routes.MapSubdomainRoute(
  99. name: "Admin.UserSearch",
  100. domains: new List<string>() { config.Host },
  101. subDomains: new List<string>() { "admin" },
  102. template: "Search/Users",
  103. defaults: new { area = "Admin", controller = "Admin", action = "UserSearch" }
  104. );
  105. routes.MapSubdomainRoute(
  106. name: "Admin.UploadSearch",
  107. domains: new List<string>() { config.Host },
  108. subDomains: new List<string>() { "admin" },
  109. template: "Search/Uploads",
  110. defaults: new { area = "Admin", controller = "Admin", action = "UploadSearch" }
  111. );
  112. routes.MapSubdomainRoute(
  113. name: "Admin.PasteSearch",
  114. domains: new List<string>() { config.Host },
  115. subDomains: new List<string>() { "admin" },
  116. template: "Search/Pastes",
  117. defaults: new { area = "Admin", controller = "Admin", action = "PasteSearch" }
  118. );
  119. routes.MapSubdomainRoute(
  120. name: "Admin.ShortenedUrlSearch",
  121. domains: new List<string>() { config.Host },
  122. subDomains: new List<string>() { "admin" },
  123. template: "Search/ShortenedUrls",
  124. defaults: new { area = "Admin", controller = "Admin", action = "ShortenedUrlSearch" }
  125. );
  126. routes.MapSubdomainRoute(
  127. name: "Admin.UserInfo",
  128. domains: new List<string>() { config.Host },
  129. subDomains: new List<string>() { "admin" },
  130. template: "User/{username}",
  131. defaults: new { area = "Admin", controller = "Admin", action = "UserInfo", username = string.Empty }
  132. );
  133. routes.MapSubdomainRoute(
  134. name: "Admin.Action",
  135. domains: new List<string>() { config.Host },
  136. subDomains: new List<string>() { "admin" },
  137. template: "Action/{action}",
  138. defaults: new { area = "Admin", controller = "Admin", action = "Dashboard" }
  139. );
  140. }
  141. public static void BuildAPIRoutes(this IRouteBuilder routes, Config config)
  142. {
  143. routes.MapSubdomainRoute(
  144. name: "API.v1.Claims",
  145. domains: new List<string>() { config.Host },
  146. subDomains: new List<string>() { "api" },
  147. template: "v1/Claims",
  148. defaults: new { area = "API", controller = "AccountAPIv1", action = "GetClaims" }
  149. );
  150. routes.MapSubdomainRoute(
  151. name: "API.v1.Upload",
  152. domains: new List<string>() { config.Host },
  153. subDomains: new List<string>() { "api" },
  154. template: "v1/Upload",
  155. defaults: new { area = "API", controller = "UploadAPIv1", action = "Upload" }
  156. );
  157. routes.MapSubdomainRoute(
  158. name: "API.v1.Paste",
  159. domains: new List<string>() { config.Host },
  160. subDomains: new List<string>() { "api" },
  161. template: "v1/Paste",
  162. defaults: new { area = "API", controller = "PasteAPIv1", action = "Paste" }
  163. );
  164. routes.MapSubdomainRoute(
  165. name: "API.v1.Shorten",
  166. domains: new List<string>() { config.Host },
  167. subDomains: new List<string>() { "api" },
  168. template: "v1/Shorten",
  169. defaults: new { area = "API", controller = "ShortenAPIv1", action = "Shorten" }
  170. );
  171. routes.MapSubdomainRoute(
  172. name: "API.Index",
  173. domains: new List<string>() { config.Host },
  174. subDomains: new List<string>() { "api" },
  175. template: "",
  176. defaults: new { area = "API", controller = "API", action = "Index" }
  177. );
  178. }
  179. public static void BuildBlogRoutes(this IRouteBuilder routes, Config config)
  180. {
  181. routes.MapSubdomainRoute(
  182. name: "Blog.Blog",
  183. domains: new List<string>() { config.Host },
  184. subDomains: new List<string>() { "blog" },
  185. template: "{username}",
  186. defaults: new { area = "Blog", controller = "Blog", action = "Blog", username = string.Empty }
  187. );
  188. routes.MapSubdomainRoute(
  189. name: "Blog.New",
  190. domains: new List<string>() { config.Host },
  191. subDomains: new List<string>() { "blog" },
  192. template: "{username}/New",
  193. defaults: new { area = "Blog", controller = "Blog", action = "NewPost", username = string.Empty }
  194. );
  195. routes.MapSubdomainRoute(
  196. name: "Blog.Edit",
  197. domains: new List<string>() { config.Host },
  198. subDomains: new List<string>() { "blog" },
  199. template: "{username}/Edit/{id}",
  200. defaults: new { area = "Blog", controller = "Blog", action = "EditPost", username = string.Empty, id = -1 }
  201. );
  202. routes.MapSubdomainRoute(
  203. name: "Blog.Post",
  204. domains: new List<string>() { config.Host },
  205. subDomains: new List<string>() { "blog" },
  206. template: "{username}/p/{id}",
  207. defaults: new { area = "Blog", controller = "Blog", action = "Post", username = string.Empty, id = -1 }
  208. );
  209. routes.MapSubdomainRoute(
  210. name: "Blog.Action",
  211. domains: new List<string>() { config.Host },
  212. subDomains: new List<string>() { "blog" },
  213. template: "Action/{action}",
  214. defaults: new { area = "Blog", controller = "Blog", action = "Blog" }
  215. );
  216. }
  217. public static void BuildContactRoutes(this IRouteBuilder routes, Config config)
  218. {
  219. routes.MapSubdomainRoute(
  220. name: "Contact.Index",
  221. domains: new List<string>() { config.Host },
  222. subDomains: new List<string>() { "contact" },
  223. template: "",
  224. defaults: new { area = "Contact", controller = "Contact", action = "Index" }
  225. );
  226. routes.MapSubdomainRoute(
  227. name: "Contact.Action",
  228. domains: new List<string>() { config.Host },
  229. subDomains: new List<string>() { "contact" },
  230. template: "Action/{action}",
  231. defaults: new { area = "Contact", controller = "Contact", action = "Index" }
  232. );
  233. }
  234. public static void BuildDevRoutes(this IRouteBuilder routes, Config config)
  235. {
  236. routes.MapSubdomainRoute(
  237. name: "Dev.Index",
  238. domains: new List<string>() { config.Host },
  239. subDomains: new List<string>() { "dev" },
  240. template: "",
  241. defaults: new { area = "Dev", controller = "Dev", action = "Index" }
  242. );
  243. }
  244. public static void BuildErrorRoutes(this IRouteBuilder routes, Config config)
  245. {
  246. routes.MapSubdomainRoute(
  247. name: "Error.HttpError",
  248. domains: new List<string>() { config.Host },
  249. subDomains: new List<string>() { "error" },
  250. template: "{statusCode:int}",
  251. defaults: new { area = "Error", controller = "Error", action = "HttpError", statusCode = 500 }
  252. );
  253. routes.MapSubdomainRoute(
  254. name: "Error.Http401",
  255. domains: new List<string>() { config.Host },
  256. subDomains: new List<string>() { "error" },
  257. template: "401",
  258. defaults: new { area = "Error", controller = "Error", action = "Http401" }
  259. );
  260. routes.MapSubdomainRoute(
  261. name: "Error.Http403",
  262. domains: new List<string>() { config.Host },
  263. subDomains: new List<string>() { "error" },
  264. template: "403",
  265. defaults: new { area = "Error", controller = "Error", action = "Http403" }
  266. );
  267. routes.MapSubdomainRoute(
  268. name: "Error.Http404",
  269. domains: new List<string>() { config.Host },
  270. subDomains: new List<string>() { "error" },
  271. template: "404",
  272. defaults: new { area = "Error", controller = "Error", action = "Http404" }
  273. );
  274. routes.MapSubdomainRoute(
  275. name: "Error.Http500",
  276. domains: new List<string>() { config.Host },
  277. subDomains: new List<string>() { "error" },
  278. template: "500",
  279. defaults: new { area = "Error", controller = "Error", action = "Http500" }
  280. );
  281. routes.MapSubdomainRoute(
  282. name: "Error.Action",
  283. domains: new List<string>() { config.Host },
  284. subDomains: new List<string>() { "error" },
  285. template: "Action/{action}",
  286. defaults: new { area = "Error", controller = "Error", action = "HttpError" }
  287. );
  288. }
  289. public static void BuildFAQRoutes(this IRouteBuilder routes, Config config)
  290. {
  291. routes.MapSubdomainRoute(
  292. name: "FAQ.Index",
  293. domains: new List<string>() { config.Host },
  294. subDomains: new List<string>() { "faq" },
  295. template: "",
  296. defaults: new { area = "FAQ", controller = "FAQ", action = "Index" }
  297. );
  298. }
  299. public static void BuildHelpRoutes(this IRouteBuilder routes, Config config)
  300. {
  301. routes.MapSubdomainRoute(
  302. name: "Help.Index",
  303. domains: new List<string>() { config.Host },
  304. subDomains: new List<string>() { "help" },
  305. template: "",
  306. defaults: new { area = "Help", controller = "Help", action = "Index" }
  307. );
  308. routes.MapSubdomainRoute(
  309. name: "Help.API",
  310. domains: new List<string>() { config.Host },
  311. subDomains: new List<string>() { "help" },
  312. template: "API/{version?}/{service?}",
  313. defaults: new { area = "Help", controller = "Help", action = "API" }
  314. );
  315. routes.MapSubdomainRoute(
  316. name: "Help.Blog",
  317. domains: new List<string>() { config.Host },
  318. subDomains: new List<string>() { "help" },
  319. template: "Blog",
  320. defaults: new { area = "Help", controller = "Help", action = "Blog" }
  321. );
  322. routes.MapSubdomainRoute(
  323. name: "Help.Git",
  324. domains: new List<string>() { config.Host },
  325. subDomains: new List<string>() { "help" },
  326. template: "Git",
  327. defaults: new { area = "Help", controller = "Help", action = "Git" }
  328. );
  329. routes.MapSubdomainRoute(
  330. name: "Help.IRC",
  331. domains: new List<string>() { config.Host },
  332. subDomains: new List<string>() { "help" },
  333. template: "IRC",
  334. defaults: new { area = "Help", controller = "Help", action = "IRC" }
  335. );
  336. routes.MapSubdomainRoute(
  337. name: "Help.Mail",
  338. domains: new List<string>() { config.Host },
  339. subDomains: new List<string>() { "help" },
  340. template: "Mail",
  341. defaults: new { area = "Help", controller = "Help", action = "Mail" }
  342. );
  343. routes.MapSubdomainRoute(
  344. name: "Help.Markdown",
  345. domains: new List<string>() { config.Host },
  346. subDomains: new List<string>() { "help" },
  347. template: "Markdown",
  348. defaults: new { area = "Help", controller = "Help", action = "Markdown" }
  349. );
  350. routes.MapSubdomainRoute(
  351. name: "Help.Mumble",
  352. domains: new List<string>() { config.Host },
  353. subDomains: new List<string>() { "help" },
  354. template: "Mumble",
  355. defaults: new { area = "Help", controller = "Help", action = "Mumble" }
  356. );
  357. routes.MapSubdomainRoute(
  358. name: "Help.RSS",
  359. domains: new List<string>() { config.Host },
  360. subDomains: new List<string>() { "help" },
  361. template: "RSS",
  362. defaults: new { area = "Help", controller = "Help", action = "RSS" }
  363. );
  364. routes.MapSubdomainRoute(
  365. name: "Help.Tools",
  366. domains: new List<string>() { config.Host },
  367. subDomains: new List<string>() { "help" },
  368. template: "Tools",
  369. defaults: new { area = "Help", controller = "Help", action = "Tools" }
  370. );
  371. routes.MapSubdomainRoute(
  372. name: "Help.Upload",
  373. domains: new List<string>() { config.Host },
  374. subDomains: new List<string>() { "help" },
  375. template: "Upload",
  376. defaults: new { area = "Help", controller = "Help", action = "Upload" }
  377. );
  378. }
  379. public static void BuildHomeRoutes(this IRouteBuilder routes, Config config)
  380. {
  381. routes.MapSubdomainRoute(
  382. name: "Home.Index",
  383. domains: new List<string>() { config.Host },
  384. subDomains: new List<string>() { "www", string.Empty },
  385. template: "",
  386. defaults: new { area = "Home", controller = "Home", action = "Index" }
  387. );
  388. }
  389. public static void BuildPasteRoutes(this IRouteBuilder routes, Config config)
  390. {
  391. routes.MapSubdomainRoute(
  392. name: "Paste.Index",
  393. domains: new List<string>() { config.Host },
  394. subDomains: new List<string>() { "paste", "p" },
  395. template: "",
  396. defaults: new { area = "Paste", controller = "Paste", action = "Index" }
  397. );
  398. routes.MapSubdomainRoute(
  399. name: "Paste.Simple",
  400. domains: new List<string>() { config.Host },
  401. subDomains: new List<string>() { "paste", "p" },
  402. template: "Simple/{url}/{password?}",
  403. defaults: new { area = "Paste", controller = "Paste", action = "ViewPaste", type = "Simple" }
  404. );
  405. routes.MapSubdomainRoute(
  406. name: "Paste.Raw",
  407. domains: new List<string>() { config.Host },
  408. subDomains: new List<string>() { "paste", "p" },
  409. template: "Raw/{url}/{password?}",
  410. defaults: new { area = "Paste", controller = "Paste", action = "ViewPaste", type = "Raw" }
  411. );
  412. routes.MapSubdomainRoute(
  413. name: "Paste.Download",
  414. domains: new List<string>() { config.Host },
  415. subDomains: new List<string>() { "paste", "p" },
  416. template: "Download/{url}/{password?}",
  417. defaults: new { area = "Paste", controller = "Paste", action = "ViewPaste", type = "Download" }
  418. );
  419. routes.MapSubdomainRoute(
  420. name: "Paste.Edit",
  421. domains: new List<string>() { config.Host },
  422. subDomains: new List<string>() { "paste", "p" },
  423. template: "Edit/{url}/{password?}",
  424. defaults: new { area = "Paste", controller = "Paste", action = "Edit" }
  425. );
  426. routes.MapSubdomainRoute(
  427. name: "Paste.Delete",
  428. domains: new List<string>() { config.Host },
  429. subDomains: new List<string>() { "paste", "p" },
  430. template: "Delete",
  431. defaults: new { area = "Paste", controller = "Paste", action = "Delete" }
  432. );
  433. routes.MapSubdomainRoute(
  434. name: "Paste.Action",
  435. domains: new List<string>() { config.Host },
  436. subDomains: new List<string>() { "paste", "p" },
  437. template: "Action/{action}",
  438. defaults: new { area = "Paste", controller = "Paste", action = "Index" }
  439. );
  440. routes.MapSubdomainRoute(
  441. name: "Paste.View",
  442. domains: new List<string>() { config.Host },
  443. subDomains: new List<string>() { "paste", "p" },
  444. template: "{url}/{password?}",
  445. defaults: new { area = "Paste", controller = "Paste", action = "ViewPaste", type = "Full" }
  446. );
  447. }
  448. public static void BuildPodcastRoutes(this IRouteBuilder routes, Config config)
  449. {
  450. routes.MapSubdomainRoute(
  451. name: "Podcast.Index",
  452. domains: new List<string>() { config.Host },
  453. subDomains: new List<string>() { "podcast" },
  454. template: "",
  455. defaults: new { area = "Podcast", controller = "Podcast", action = "Index" }
  456. );
  457. routes.MapSubdomainRoute(
  458. name: "Podcast.View",
  459. domains: new List<string>() { config.Host },
  460. subDomains: new List<string>() { "podcast" },
  461. template: "ep/{episode}",
  462. defaults: new { area = "Podcast", controller = "Podcast", action = "View" }
  463. );
  464. routes.MapSubdomainRoute(
  465. name: "Podcast.Download",
  466. domains: new List<string>() { config.Host },
  467. subDomains: new List<string>() { "podcast" },
  468. template: "File/{episode}/{fileName}",
  469. defaults: new { area = "Podcast", controller = "Podcast", action = "Download" }
  470. );
  471. routes.MapSubdomainRoute(
  472. name: "Podcast.Action",
  473. domains: new List<string>() { config.Host },
  474. subDomains: new List<string>() { "podcast" },
  475. template: "Action/{action}",
  476. defaults: new { area = "Podcast", controller = "Podcast", action = "Index" }
  477. );
  478. }
  479. public static void BuildPrivacyRoutes(this IRouteBuilder routes, Config config)
  480. {
  481. routes.MapSubdomainRoute(
  482. name: "Privacy.Index",
  483. domains: new List<string>() { config.Host },
  484. subDomains: new List<string>() { "privacy" },
  485. template: "",
  486. defaults: new { area = "Privacy", controller = "Privacy", action = "Index" }
  487. );
  488. }
  489. public static void BuildRSSRoutes(this IRouteBuilder routes, Config config)
  490. {
  491. routes.MapSubdomainRoute(
  492. name: "RSS.Index",
  493. domains: new List<string>() { config.Host },
  494. subDomains: new List<string>() { "rss" },
  495. template: "",
  496. defaults: new { area = "RSS", controller = "RSS", action = "Index" }
  497. );
  498. routes.MapSubdomainRoute(
  499. name: "RSS.Blog",
  500. domains: new List<string>() { config.Host },
  501. subDomains: new List<string>() { "rss" },
  502. template: "Blog/{username?}",
  503. defaults: new { area = "RSS", controller = "RSS", action = "Blog" }
  504. );
  505. routes.MapSubdomainRoute(
  506. name: "RSS.Podcast",
  507. domains: new List<string>() { config.Host },
  508. subDomains: new List<string>() { "rss" },
  509. template: "Podcast",
  510. defaults: new { area = "RSS", controller = "RSS", action = "Podcast" }
  511. );
  512. }
  513. public static void BuildShortenerRoutes(this IRouteBuilder routes, Config config)
  514. {
  515. routes.MapSubdomainRoute(
  516. name: "Shortener.Index",
  517. domains: new List<string>() { config.Host },
  518. subDomains: new List<string>() { "shorten", "s" },
  519. template: "",
  520. defaults: new { area = "Shortener", controller = "Shortener", action = "Index" }
  521. );
  522. routes.MapSubdomainRoute(
  523. name: "Shortener.Delete",
  524. domains: new List<string>() { config.Host },
  525. subDomains: new List<string>() { "shorten", "s" },
  526. template: "Delete",
  527. defaults: new { area = "Shortener", controller = "Shortener", action = "Delete" }
  528. );
  529. routes.MapSubdomainRoute(
  530. name: "Shortener.Action",
  531. domains: new List<string>() { config.Host },
  532. subDomains: new List<string>() { "shorten", "s" },
  533. template: "Action/{action}",
  534. defaults: new { area = "Shortener", controller = "Shortener", action = "Index" }
  535. );
  536. routes.MapSubdomainRoute(
  537. name: "Shortener.View",
  538. domains: new List<string>() { config.ShortenerConfig.ShortenerHost, config.Host },
  539. subDomains: new List<string>() { string.Empty, "shortened" },
  540. template: "{url}",
  541. defaults: new { area = "Shortener", controller = "Shortener", action = "RedirectToUrl" }
  542. );
  543. routes.MapSubdomainRoute(
  544. name: "Shortener.Verify",
  545. domains: new List<string>() { config.ShortenerConfig.ShortenerHost },
  546. subDomains: new List<string>() { string.Empty },
  547. template: "",
  548. defaults: new { area = "Shortener", controller = "Shortener", action = "Verify" }
  549. );
  550. }
  551. public static void BuildStatsRoutes(this IRouteBuilder routes, Config config)
  552. {
  553. routes.MapSubdomainRoute(
  554. name: "Stats.Index",
  555. domains: new List<string>() { config.Host },
  556. subDomains: new List<string>() { "stats" },
  557. template: "",
  558. defaults: new { area = "Stats", controller = "Stats", action = "Index" }
  559. );
  560. routes.MapSubdomainRoute(
  561. name: "Stats.Action",
  562. domains: new List<string>() { config.Host },
  563. subDomains: new List<string>() { "stats" },
  564. template: "Action/{action}",
  565. defaults: new { area = "Stats", controller = "Stats", action = "Index" }
  566. );
  567. }
  568. public static void BuildTOSRoutes(this IRouteBuilder routes, Config config)
  569. {
  570. routes.MapSubdomainRoute(
  571. name: "TOS.Index",
  572. domains: new List<string>() { config.Host },
  573. subDomains: new List<string>() { "tos" },
  574. template: "",
  575. defaults: new { area = "TOS", controller = "TOS", action = "Index" }
  576. );
  577. }
  578. public static void BuildUploadRoutes(this IRouteBuilder routes, Config config)
  579. {
  580. routes.MapSubdomainRoute(
  581. name: "Upload.Index",
  582. domains: new List<string>() { config.Host },
  583. subDomains: new List<string>() { "upload", "u" },
  584. template: "",
  585. defaults: new { area = "Upload", controller = "Upload", action = "Index" }
  586. );
  587. routes.MapSubdomainRoute(
  588. name: "Upload.GenerateDeleteKey",
  589. domains: new List<string>() { config.Host },
  590. subDomains: new List<string>() { "upload", "u", "user" },
  591. template: "GenerateDeleteKey",
  592. defaults: new { area = "Upload", controller = "Upload", action = "GenerateDeleteKey" }
  593. );
  594. routes.MapSubdomainRoute(
  595. name: "Upload.Delete",
  596. domains: new List<string>() { config.Host },
  597. subDomains: new List<string>() { "upload", "u" },
  598. template: "Delete",
  599. defaults: new { area = "Upload", controller = "Upload", action = "Delete" }
  600. );
  601. routes.MapSubdomainRoute(
  602. name: "Upload.Download",
  603. domains: new List<string>() { config.Host },
  604. subDomains: new List<string>() { "upload", "u" },
  605. template: "{file}",
  606. defaults: new { area = "Upload", controller = "Upload", action = "Download" }
  607. );
  608. routes.MapSubdomainRoute(
  609. name: "Upload.DeleteByKey",
  610. domains: new List<string>() { config.Host },
  611. subDomains: new List<string>() { "upload", "u" },
  612. template: "{file}/{key}",
  613. defaults: new { area = "Upload", controller = "Upload", action = "DeleteByKey" }
  614. );
  615. routes.MapSubdomainRoute(
  616. name: "Upload.Action",
  617. domains: new List<string>() { config.Host },
  618. subDomains: new List<string>() { "upload", "u" },
  619. template: "Action/{action}",
  620. defaults: new { area = "Upload", controller = "Upload", action = "Index" }
  621. );
  622. }
  623. public static void BuildUserRoutes(this IRouteBuilder routes, Config config)
  624. {
  625. routes.MapSubdomainRoute(
  626. name: "User.Index",
  627. domains: new List<string>() { config.Host },
  628. subDomains: new List<string>() { "account" },
  629. template: "",
  630. defaults: new { area = "User", controller = "User", action = "Index" }
  631. );
  632. routes.MapSubdomainRoute(
  633. name: "User.GetPremium",
  634. domains: new List<string>() { config.Host },
  635. subDomains: new List<string>() { "account" },
  636. template: "GetPremium",
  637. defaults: new { area = "User", controller = "User", action = "GetPremium" }
  638. );
  639. routes.MapSubdomainRoute(
  640. name: "User.Register",
  641. domains: new List<string>() { config.Host },
  642. subDomains: new List<string>() { "account" },
  643. template: "Register",
  644. defaults: new { area = "User", controller = "User", action = "Register" }
  645. );
  646. routes.MapSubdomainRoute(
  647. name: "User.Login",
  648. domains: new List<string>() { config.Host },
  649. subDomains: new List<string>() { "account" },
  650. template: "Login",
  651. defaults: new { area = "User", controller = "User", action = "Login" }
  652. );
  653. routes.MapSubdomainRoute(
  654. name: "User.Logout",
  655. domains: new List<string>() { config.Host },
  656. subDomains: new List<string>() { "account" },
  657. template: "Logout",
  658. defaults: new { area = "User", controller = "User", action = "Logout" }
  659. );
  660. routes.MapSubdomainRoute(
  661. name: "User.Settings",
  662. domains: new List<string>() { config.Host },
  663. subDomains: new List<string>() { "account" },
  664. template: "Settings",
  665. defaults: new { area = "User", controller = "User", action = "Settings" }
  666. );
  667. routes.MapSubdomainRoute(
  668. name: "User.AccountSettings",
  669. domains: new List<string>() { config.Host },
  670. subDomains: new List<string>() { "account" },
  671. template: "Settings/Account",
  672. defaults: new { area = "User", controller = "User", action = "AccountSettings" }
  673. );
  674. routes.MapSubdomainRoute(
  675. name: "User.SecuritySettings",
  676. domains: new List<string>() { config.Host },
  677. subDomains: new List<string>() { "account" },
  678. template: "Settings/Security",
  679. defaults: new { area = "User", controller = "User", action = "SecuritySettings" }
  680. );
  681. routes.MapSubdomainRoute(
  682. name: "User.ProfileSettings",
  683. domains: new List<string>() { config.Host },
  684. subDomains: new List<string>() { "account" },
  685. template: "Settings/Profile",
  686. defaults: new { area = "User", controller = "User", action = "ProfileSettings" }
  687. );
  688. routes.MapSubdomainRoute(
  689. name: "User.DeveloperSettings",
  690. domains: new List<string>() { config.Host },
  691. subDomains: new List<string>() { "account" },
  692. template: "Settings/Developer",
  693. defaults: new { area = "User", controller = "User", action = "DeveloperSettings" }
  694. );
  695. routes.MapSubdomainRoute(
  696. name: "User.InviteSettings",
  697. domains: new List<string>() { config.Host },
  698. subDomains: new List<string>() { "account" },
  699. template: "Settings/Invites",
  700. defaults: new { area = "User", controller = "User", action = "InviteSettings" }
  701. );
  702. routes.MapSubdomainRoute(
  703. name: "User.BlogSettings",
  704. domains: new List<string>() { config.Host },
  705. subDomains: new List<string>() { "account" },
  706. template: "Settings/Blog",
  707. defaults: new { area = "User", controller = "User", action = "BlogSettings" }
  708. );
  709. routes.MapSubdomainRoute(
  710. name: "User.UploadSettings",
  711. domains: new List<string>() { config.Host },
  712. subDomains: new List<string>() { "account" },
  713. template: "Settings/Uploads",
  714. defaults: new { area = "User", controller = "User", action = "UploadSettings" }
  715. );
  716. routes.MapSubdomainRoute(
  717. name: "User.ResetPassword",
  718. domains: new List<string>() { config.Host },
  719. subDomains: new List<string>() { "account" },
  720. template: "ResetPassword/{username?}",
  721. defaults: new { area = "User", controller = "User", action = "ResetPassword" }
  722. );
  723. routes.MapSubdomainRoute(
  724. name: "User.VerifyResetPassword",
  725. domains: new List<string>() { config.Host },
  726. subDomains: new List<string>() { "account" },
  727. template: "SetPassword/{username}",
  728. defaults: new { area = "User", controller = "User", action = "VerifyResetPassword" }
  729. );
  730. routes.MapSubdomainRoute(
  731. name: "User.VerifyRecoveryEmail",
  732. domains: new List<string>() { config.Host },
  733. subDomains: new List<string>() { "account" },
  734. template: "VerifyEmail/{username}",
  735. defaults: new { area = "User", controller = "User", action = "VerifyRecoveryEmail" }
  736. );
  737. routes.MapSubdomainRoute(
  738. name: "User.ViewServiceData",
  739. domains: new List<string>() { config.Host },
  740. subDomains: new List<string>() { "account" },
  741. template: "ServiceData",
  742. defaults: new { area = "User", controller = "User", action = "ViewServiceData" }
  743. );
  744. routes.MapSubdomainRoute(
  745. name: "User.Action",
  746. domains: new List<string>() { config.Host },
  747. subDomains: new List<string>() { "account" },
  748. template: "Action/{action}",
  749. defaults: new { area = "User", controller = "User", action = "Index" }
  750. );
  751. routes.MapSubdomainRoute(
  752. name: "User.ViewProfile",
  753. domains: new List<string>() { config.Host },
  754. subDomains: new List<string>() { "user" },
  755. template: "{username?}",
  756. defaults: new { area = "User", controller = "User", action = "ViewProfile" }
  757. );
  758. routes.MapSubdomainRoute(
  759. name: "User.PGPKey",
  760. domains: new List<string>() { config.Host },
  761. subDomains: new List<string>() { "user" },
  762. template: "{username}/PGP",
  763. defaults: new { area = "User", controller = "User", action = "ViewRawPGP" }
  764. );
  765. }
  766. public static void BuildVaultRoutes(this IRouteBuilder routes, Config config)
  767. {
  768. routes.MapSubdomainRoute(
  769. name: "Vault.Index",
  770. domains: new List<string>() { config.Host },
  771. subDomains: new List<string>() { "vault", "v" },
  772. template: "",
  773. defaults: new { area = "Vault", controller = "Vault", action = "Index" }
  774. );
  775. routes.MapSubdomainRoute(
  776. name: "Vault.NewVault",
  777. domains: new List<string>() { config.Host },
  778. subDomains: new List<string>() { "vault", "v" },
  779. template: "Create",
  780. defaults: new { area = "Vault", controller = "Vault", action = "NewVault" }
  781. );
  782. routes.MapSubdomainRoute(
  783. name: "Vault.NewVaultFromService",
  784. domains: new List<string>() { config.Host },
  785. subDomains: new List<string>() { "vault", "v" },
  786. template: "Create/{type}",
  787. defaults: new { area = "Vault", controller = "Vault", action = "NewVaultFromService" }
  788. );
  789. routes.MapSubdomainRoute(
  790. name: "Vault.EditVault",
  791. domains: new List<string>() { config.Host },
  792. subDomains: new List<string>() { "vault", "v" },
  793. template: "Edit/{url}",
  794. defaults: new { area = "Vault", controller = "Vault", action = "EditVault" }
  795. );
  796. routes.MapSubdomainRoute(
  797. name: "Vault.Delete",
  798. domains: new List<string>() { config.Host },
  799. subDomains: new List<string>() { "vault", "v" },
  800. template: "Delete",
  801. defaults: new { area = "Vault", controller = "Vault", action = "Delete" }
  802. );
  803. routes.MapSubdomainRoute(
  804. name: "Vault.ViewVault",
  805. domains: new List<string>() { config.Host },
  806. subDomains: new List<string>() { "vault", "v" },
  807. template: "v/{id}",
  808. defaults: new { area = "Vault", controller = "Vault", action = "ViewVault" }
  809. );
  810. routes.MapSubdomainRoute(
  811. name: "Vault.Action",
  812. domains: new List<string>() { config.Host },
  813. subDomains: new List<string>() { "vault", "v" },
  814. template: "Action/{action}",
  815. defaults: new { area = "Vault", controller = "Vault", action = "Index" }
  816. );
  817. }
  818. }
  819. }