source: binary-improvements2/MapRendering/Web/API/GetWebMods.cs@ 386

Last change on this file since 386 was 384, checked in by alloc, 3 years ago

Added support for webmods to the backend

File size: 1.2 KB
RevLine 
[384]1using AllocsFixes.JSON;
2using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;
3using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
4
5namespace AllocsFixes.NetConnections.Servers.Web.API {
6 public class GetWebMods : WebAPI {
7 private readonly JSONArray loadedWebMods = new JSONArray ();
8
9 public GetWebMods (Web _parent) {
10 foreach (WebMod webMod in _parent.webMods) {
11 JSONObject modJson = new JSONObject ();
12
13 modJson.Add ("name", new JSONString (webMod.ParentMod.ModInfo.Name.Value));
14
15 string webModReactBundle = webMod.ReactBundle;
16 if (webModReactBundle != null) {
17 modJson.Add ("bundle", new JSONString (webModReactBundle));
18 }
19
20 string webModCssFile = webMod.CssPath;
21 if (webModCssFile != null) {
22 modJson.Add ("css", new JSONString (webModCssFile));
23 }
24
25 loadedWebMods.Add (modJson);
26 }
27 }
28
29 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,
30 int _permissionLevel) {
31
32 WriteJSON (_resp, loadedWebMods);
33 }
34
35 public override int DefaultPermissionLevel () {
36 return 2000;
37 }
38 }
39}
Note: See TracBrowser for help on using the repository browser.