|
Last change
on this file since 425 was 425, checked in by alloc, 3 years ago |
- API "map" added, currently only supports GET with the ID "config"
- API "player" added, currently only supports getting online players with some of the info not supported yet (playtime, last online, level)
- Only logged in player's data is shown unless the user has the permission for "webapi.viewallplayers"
- Internal refactoring
- (Updated version to 21.0.258)
|
|
File size:
1009 bytes
|
| Line | |
|---|
| 1 | using System.Net;
|
|---|
| 2 | using JetBrains.Annotations;
|
|---|
| 3 | using Utf8Json;
|
|---|
| 4 | using Webserver;
|
|---|
| 5 | using Webserver.WebAPI;
|
|---|
| 6 |
|
|---|
| 7 | namespace MapRendering.Api {
|
|---|
| 8 | [UsedImplicitly]
|
|---|
| 9 | public class Map : AbsRestApi {
|
|---|
| 10 |
|
|---|
| 11 | private static readonly byte[] jsonEnabledKey = JsonWriter.GetEncodedPropertyNameWithBeginObject ("enabled");
|
|---|
| 12 |
|
|---|
| 13 | protected override void HandleRestGet (RequestContext _context) {
|
|---|
| 14 | string id = _context.RequestPath;
|
|---|
| 15 |
|
|---|
| 16 | PrepareEnvelopedResult (out JsonWriter writer);
|
|---|
| 17 |
|
|---|
| 18 | switch (id) {
|
|---|
| 19 | case "config":
|
|---|
| 20 | writer.WriteRaw (jsonEnabledKey);
|
|---|
| 21 | writer.WriteBoolean (MapRenderer.Enabled);
|
|---|
| 22 | writer.WriteEndObject ();
|
|---|
| 23 | break;
|
|---|
| 24 | default:
|
|---|
| 25 | SendErrorResult (_context, HttpStatusCode.NotImplemented, _errorCode: "INVALID_ID");
|
|---|
| 26 | return;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | SendEnvelopedResult (_context, ref writer);
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | public override int DefaultMethodPermissionLevel (ERequestMethod _method) {
|
|---|
| 33 | return _method switch {
|
|---|
| 34 | ERequestMethod.GET => 2000,
|
|---|
| 35 | _ => base.DefaultMethodPermissionLevel (_method)
|
|---|
| 36 | };
|
|---|
| 37 | }
|
|---|
| 38 | }
|
|---|
| 39 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.