diff --git a/resource/api_ref.swagger.yml b/resource/api_ref.swagger.yml new file mode 100644 index 0000000..ea60424 --- /dev/null +++ b/resource/api_ref.swagger.yml @@ -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 + \ No newline at end of file diff --git a/resource/main.go b/resource/main.go index c17a903..fc910a1 100644 --- a/resource/main.go +++ b/resource/main.go @@ -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))