source: binary-improvements2/MapRendering/src/Api/Map.cs@ 438

Last change on this file since 438 was 434, checked in by alloc, 18 months ago

Added permission management APIs

File size: 1.1 KB
Line 
1using System.Net;
2using JetBrains.Annotations;
3using Utf8Json;
4using Webserver;
5using Webserver.Permissions;
6using Webserver.WebAPI;
7
8namespace MapRendering.Api {
9 [UsedImplicitly]
10 public class Map : AbsRestApi {
11
12 private static readonly byte[] jsonEnabledKey = JsonWriter.GetEncodedPropertyNameWithBeginObject ("enabled");
13
14 protected override void HandleRestGet (RequestContext _context) {
15 string id = _context.RequestPath;
16
17 PrepareEnvelopedResult (out JsonWriter writer);
18
19 switch (id) {
20 case "config":
21 writer.WriteRaw (jsonEnabledKey);
22 writer.WriteBoolean (MapRenderer.Enabled);
23 writer.WriteEndObject ();
24 break;
25 default:
26 SendEmptyResponse (_context, HttpStatusCode.NotImplemented, _errorCode: "INVALID_ID");
27 return;
28 }
29
30 SendEnvelopedResult (_context, ref writer);
31 }
32
33 public override int[] DefaultMethodPermissionLevels () => new[] {
34 AdminWebModules.MethodLevelNotSupported,
35 AdminWebModules.PermissionLevelGuest,
36 AdminWebModules.MethodLevelInheritGlobal,
37 AdminWebModules.MethodLevelInheritGlobal,
38 AdminWebModules.MethodLevelInheritGlobal
39 };
40 }
41}
Note: See TracBrowser for help on using the repository browser.