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.

APIAreaRegistration.cs 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System.Collections.Generic;
  2. using System.Web.Mvc;
  3. using Teknik.Configuration;
  4. namespace Teknik.Areas.API
  5. {
  6. public class APIAreaRegistration : AreaRegistration
  7. {
  8. public override string AreaName
  9. {
  10. get
  11. {
  12. return "API";
  13. }
  14. }
  15. public override void RegisterArea(AreaRegistrationContext context)
  16. {
  17. Config config = Config.Load();
  18. #region API v1
  19. // Base Routing
  20. context.MapSubdomainRoute(
  21. "API.v1.Index", // Route name
  22. new List<string>() { "api" },
  23. new List<string>() { config.Host },
  24. "v1", // URL with parameters
  25. new { controller = "APIv1", action = "Index" }, // Parameter defaults
  26. new[] { typeof(Controllers.APIv1Controller).Namespace }
  27. );
  28. // Uploads
  29. context.MapSubdomainRoute(
  30. "API.v1.Upload", // Route name
  31. new List<string>() { "api" },
  32. new List<string>() { config.Host },
  33. "v1/Upload", // URL with parameters
  34. new { controller = "APIv1", action = "Upload" }, // Parameter defaults
  35. new[] { typeof(Controllers.APIv1Controller).Namespace }
  36. );
  37. // Pastes
  38. context.MapSubdomainRoute(
  39. "API.v1.Paste", // Route name
  40. new List<string>() { "api" },
  41. new List<string>() { config.Host },
  42. "v1/Paste", // URL with parameters
  43. new { controller = "APIv1", action = "Paste" }, // Parameter defaults
  44. new[] { typeof(Controllers.APIv1Controller).Namespace }
  45. );
  46. // Url Shortening
  47. context.MapSubdomainRoute(
  48. "API.v1.Shortener", // Route name
  49. new List<string>() { "api" },
  50. new List<string>() { config.Host },
  51. "v1/Shorten", // URL with parameters
  52. new { controller = "APIv1", action = "Shorten" }, // Parameter defaults
  53. new[] { typeof(Controllers.APIv1Controller).Namespace }
  54. );
  55. #endregion
  56. // Default Routing
  57. context.MapSubdomainRoute(
  58. "API.Index", // Route name
  59. new List<string>() { "api" },
  60. new List<string>() { config.Host },
  61. "", // URL with parameters
  62. new { controller = "API", action = "Index" }, // Parameter defaults
  63. new[] { typeof(Controllers.APIController).Namespace }
  64. );
  65. }
  66. }
  67. }