add swagger reference

This commit is contained in:
blek 2023-11-05 15:49:44 +10:00
parent 77970e86e7
commit b306ab3eb6
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,48 @@
openapi: 3.0.3
info:
title: ResourceD API
description: |-
This is the ResourceD API docs.
license:
name: GPLv3
url: https://www.gnu.org/licenses/gpl-3.0.en.html
version: "1.0"
servers:
- url: http://localhost/resource
tags:
- name: Data API
description: API for serving data
- name: System API
description: API for serving system data
paths:
/{id}:
get:
description: Get a resource
summary: Get a resource. Send browser requests to this URL
tags:
- Data API
responses:
200:
description: Returns a resource in its binary data
302:
description: Resource is an external (http) link and the redirect is being forwarded to that link
404:
description: Not found
500:
description: Internal error
/info/is_enabled:
get:
description: Check if resourceD is enabled
summary: Check if resourceD is enabled
tags:
- System API
responses:
200:
description: Ok
content:
application/json:
schema:
type: boolean
example: true

View File

@ -119,7 +119,8 @@ func main() {
if err != nil {
log.Fatalln(err)
// we failed, send a redirect instead
// (next executed line would be 115)
// the next line would be the one with
// c.Location(res.Url)
} else {
c.Response().Header.SetContentType(res.Mime)
c.Response().Header.SetContentLength(len(data))