forked from inexorabletash/travellermap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlobal.asax.cs
More file actions
129 lines (103 loc) · 11.2 KB
/
Global.asax.cs
File metadata and controls
129 lines (103 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using Json;
using Maps.Admin;
using Maps.API;
using Maps.HTTP;
using System;
using System.Globalization;
using System.Web.Routing;
namespace Maps
{
public class GlobalAsax : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
RegisterRoutes(RouteTable.Routes);
}
private static void RegisterRoutes(RouteCollection routes)
{
var DEFAULT_JSON = new RouteValueDictionary { { "accept", JsonConstants.MediaType } };
// Navigation --------------------------------------------------
routes.Add(new RegexRoute(@"/go/(?<sector>[^/]+)", new RedirectRouteHandler("/?sector={sector}", statusCode: 302)));
routes.Add(new RegexRoute(@"/go/(?<sector>[^/]+)/(?<hex>[0-9]{4})", new RedirectRouteHandler("/?sector={sector}&hex={hex}", statusCode: 302)));
routes.Add(new RegexRoute(@"/go/(?<sector>[^/]+)/(?<subsector>[^/]+)", new RedirectRouteHandler("/?sector={sector}&subsector={subsector}", statusCode: 302)));
routes.Add(new RegexRoute(@"/booklet/(?<sector>[^/]+)", new RedirectRouteHandler("/make/booklet?sector={sector}", statusCode: 302)));
routes.Add(new RegexRoute(@"/sheet/(?<sector>[^/]+)/(?<hex>[0-9]{4})", new RedirectRouteHandler("/print/world?sector={sector}&hex={hex}", statusCode: 302)));
// Administration -----------------------------------------------
routes.Add(new RegexRoute(@"/admin/admin", new GenericRouteHandler(typeof(AdminHandler))));
routes.Add(new RegexRoute(@"/admin/flush", new GenericRouteHandler(typeof(AdminHandler)),
new RouteValueDictionary(new { action = "flush" })));
routes.Add(new RegexRoute(@"/admin/reindex", new GenericRouteHandler(typeof(AdminHandler)),
new RouteValueDictionary(new { action = "reindex" })));
routes.Add(new RegexRoute(@"/admin/profile", new GenericRouteHandler(typeof(AdminHandler)),
new RouteValueDictionary(new { action = "profile" })));
routes.Add(new RegexRoute(@"/admin/codes", new GenericRouteHandler(typeof(CodesHandler))));
routes.Add(new RegexRoute(@"/admin/dump", new GenericRouteHandler(typeof(DumpHandler))));
routes.Add(new RegexRoute(@"/admin/errors", new GenericRouteHandler(typeof(ErrorsHandler))));
routes.Add(new RegexRoute(@"/admin/overview", new GenericRouteHandler(typeof(OverviewHandler))));
// Search -------------------------------------------------------
routes.Add(new RegexRoute(@"/api/search", new GenericRouteHandler(typeof(SearchHandler)), DEFAULT_JSON));
routes.Add(new RegexRoute(@"/api/route", new GenericRouteHandler(typeof(RouteHandler)), DEFAULT_JSON));
// Rendering ----------------------------------------------------
routes.Add(new RegexRoute(@"/api/jumpmap", new GenericRouteHandler(typeof(JumpMapHandler))));
routes.Add(new RegexRoute(@"/api/poster", new GenericRouteHandler(typeof(PosterHandler))));
routes.Add(new RegexRoute(@"/api/poster/(?<sector>[^/]+)", new GenericRouteHandler(typeof(PosterHandler))));
routes.Add(new RegexRoute(@"/api/poster/(?<sector>[^/]+)/(?<quadrant>(?:alpha|beta|gamma|delta))", new GenericRouteHandler(typeof(PosterHandler))));
routes.Add(new RegexRoute(@"/api/poster/(?<sector>[^/]+)/(?<subsector>[^/]+)", new GenericRouteHandler(typeof(PosterHandler))));
routes.Add(new RegexRoute(@"/api/tile", new GenericRouteHandler(typeof(TileHandler))));
// Location Queries ---------------------------------------------
routes.Add(new RegexRoute(@"/api/coordinates", new GenericRouteHandler(typeof(CoordinatesHandler)), DEFAULT_JSON));
routes.Add(new RegexRoute(@"/api/credits", new GenericRouteHandler(typeof(CreditsHandler)), DEFAULT_JSON));
routes.Add(new RegexRoute(@"/api/jumpworlds", new GenericRouteHandler(typeof(JumpWorldsHandler)), DEFAULT_JSON));
// Data Retrieval - API-centric ---------------------------------
routes.Add(new RegexRoute(@"/api/universe", new GenericRouteHandler(typeof(UniverseHandler)), DEFAULT_JSON));
routes.Add(new RegexRoute(@"/api/milieux", new GenericRouteHandler(typeof(MilieuxCodesHandler)), DEFAULT_JSON));
routes.Add(new RegexRoute(@"/api/sec", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "type", "SecondSurvey" } }));
routes.Add(new RegexRoute(@"/api/sec/(?<sector>[^/]+)", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "type", "SecondSurvey" } }));
routes.Add(new RegexRoute(@"/api/sec/(?<sector>[^/]+)/(?<quadrant>alpha|beta|gamma|delta)", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "type", "SecondSurvey" }, { "metadata", 0 } }));
routes.Add(new RegexRoute(@"/api/sec/(?<sector>[^/]+)/(?<subsector>[^/]+)", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "type", "SecondSurvey" }, { "metadata", 0 } }));
routes.Add(new RegexRoute(@"/api/metadata", new GenericRouteHandler(typeof(SectorMetaDataHandler)), DEFAULT_JSON));
routes.Add(new RegexRoute(@"/api/metadata/(?<sector>[^/]+)", new GenericRouteHandler(typeof(SectorMetaDataHandler)), DEFAULT_JSON));
routes.Add(new RegexRoute(@"/api/msec", new GenericRouteHandler(typeof(MSECHandler))));
routes.Add(new RegexRoute(@"/api/msec/(?<sector>[^/]+)", new GenericRouteHandler(typeof(MSECHandler))));
// Data Retrieval - RESTful -------------------------------------
routes.Add(new RegexRoute(@"/data", new GenericRouteHandler(typeof(UniverseHandler)), DEFAULT_JSON));
// Sector, e.g. /data/Spinward Marches
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "type", "SecondSurvey" } }));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/sec", new GenericRouteHandler(typeof(SECHandler))));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/tab", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "type", "TabDelimited" } }));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/coordinates", new GenericRouteHandler(typeof(CoordinatesHandler)), DEFAULT_JSON));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/credits", new GenericRouteHandler(typeof(CreditsHandler)), DEFAULT_JSON));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/metadata", new GenericRouteHandler(typeof(SectorMetaDataHandler)))); // NOTE: XML by default
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/msec", new GenericRouteHandler(typeof(MSECHandler))));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/image", new GenericRouteHandler(typeof(PosterHandler))));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/booklet", new RedirectRouteHandler("/make/booklet?sector={sector}", statusCode: 302)));
// Quadrant, e.g. /data/Spinward Marches/Alpha
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<quadrant>alpha|beta|gamma|delta)", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "type", "SecondSurvey" }, { "metadata", "0" } }));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<quadrant>alpha|beta|gamma|delta)/sec", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "metadata", "0" } }));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<quadrant>alpha|beta|gamma|delta)/tab", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "type", "TabDelimited" }, { "metadata", "0" } }));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<quadrant>alpha|beta|gamma|delta)/image", new GenericRouteHandler(typeof(PosterHandler))));
// Subsector by Index, e.g. /data/Spinward Marches/C
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[A-Pa-p])", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "type", "SecondSurvey" }, { "metadata", "0" } }));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[A-Pa-p])/sec", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "metadata", "0" } }));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[A-Pa-p])/tab", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "type", "TabDelimited" }, { "metadata", "0" } }));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[A-Pa-p])/image", new GenericRouteHandler(typeof(PosterHandler))));
// World e.g. /data/Spinward Marches/1910
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})", new GenericRouteHandler(typeof(JumpWorldsHandler)), new RouteValueDictionary { { "accept", JsonConstants.MediaType }, { "jump", "0" } }));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})/coordinates", new GenericRouteHandler(typeof(CoordinatesHandler)), DEFAULT_JSON));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})/credits", new GenericRouteHandler(typeof(CreditsHandler)), DEFAULT_JSON));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})/jump/(?<jump>\d+)", new GenericRouteHandler(typeof(JumpWorldsHandler)), DEFAULT_JSON));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})/image", new GenericRouteHandler(typeof(JumpMapHandler)), new RouteValueDictionary { { "jump", "0" } }));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})/jump/(?<jump>\d+)/image", new GenericRouteHandler(typeof(JumpMapHandler))));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})/sheet", new RedirectRouteHandler("/print/world?sector={sector}&hex={hex}", statusCode: 302)));
// Subsector by Name e.g. /data/Spinward Marches/Regina
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[^/]+)", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "type", "SecondSurvey" }, { "metadata", "0" } }));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[^/]+)/sec", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "metadata", "0" } }));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[^/]+)/tab", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary { { "type", "TabDelimited" }, { "metadata", "0" } }));
routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[^/]+)/image", new GenericRouteHandler(typeof(PosterHandler))));
// T5SS Stock Data -------------------------------------
routes.Add(new RegexRoute(@"/t5ss/allegiances", new GenericRouteHandler(typeof(AllegianceCodesHandler)), DEFAULT_JSON));
routes.Add(new RegexRoute(@"/t5ss/sophonts", new GenericRouteHandler(typeof(SophontCodesHandler)), DEFAULT_JSON));
}
}
}