Last change
on this file since 465 was 459, checked in by alloc, 15 months ago |
Updated to dashboard/marker files 0.8.0
Added initial OpenAPI support
|
File size:
737 bytes
|
Line | |
---|
1 | using System.Net;
|
---|
2 | using JetBrains.Annotations;
|
---|
3 | using Webserver.Permissions;
|
---|
4 |
|
---|
5 | namespace Webserver.WebAPI.APIs {
|
---|
6 | [UsedImplicitly]
|
---|
7 | public class OpenAPI : AbsRestApi {
|
---|
8 | public OpenAPI (Web _parentWeb) : base (_parentWeb) {
|
---|
9 | }
|
---|
10 |
|
---|
11 | protected override void HandleRestGet (RequestContext _context) {
|
---|
12 | string path = _context.RequestPath;
|
---|
13 |
|
---|
14 | if (!ParentWeb.OpenApiHelpers.TryGetOpenApiSpec (path, out string specText)) {
|
---|
15 | WebUtils.WriteText (_context.Response, $"Spec for {path} not found", HttpStatusCode.NotFound);
|
---|
16 | return;
|
---|
17 | }
|
---|
18 |
|
---|
19 | WebUtils.WriteText (_context.Response, specText, _mimeType: "text/x-yaml");
|
---|
20 | }
|
---|
21 |
|
---|
22 | public override int DefaultPermissionLevel () => AdminWebModules.PermissionLevelGuest;
|
---|
23 | }
|
---|
24 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.