Added first stub for swagger docs.
This commit is contained in:
parent
fc5e3a6728
commit
b9d6c06c82
@ -11,8 +11,20 @@ import (
|
|||||||
"github.com/labstack/echo"
|
"github.com/labstack/echo"
|
||||||
"github.com/labstack/echo/middleware"
|
"github.com/labstack/echo/middleware"
|
||||||
"github.com/zfjagann/golang-ring"
|
"github.com/zfjagann/golang-ring"
|
||||||
|
"github.com/swaggo/echo-swagger"
|
||||||
|
_ "github.com/42wim/matterbridge/docs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// @title Matterbridge API
|
||||||
|
// @version TODO
|
||||||
|
// @description A read/write API for the Matterbridge chat bridge.
|
||||||
|
|
||||||
|
// @license.name Apache 2.0
|
||||||
|
// @license.url https://github.com/42wim/matterbridge/blob/master/LICENSE
|
||||||
|
|
||||||
|
// @host TODO
|
||||||
|
// @basePath /api
|
||||||
|
|
||||||
type API struct {
|
type API struct {
|
||||||
Messages ring.Ring
|
Messages ring.Ring
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
@ -41,6 +53,10 @@ func New(cfg *bridge.Config) bridge.Bridger {
|
|||||||
return key == b.GetString("Token"), nil
|
return key == b.GetString("Token"), nil
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
e.GET("/swagger/*", echoSwagger.WrapHandler)
|
||||||
|
e.GET("/swagger", b.handleDocsRedirect)
|
||||||
|
e.GET("/", b.handleDocsRedirect)
|
||||||
|
e.GET("/api", b.handleDocsRedirect)
|
||||||
e.GET("/api/health", b.handleHealthcheck)
|
e.GET("/api/health", b.handleHealthcheck)
|
||||||
e.GET("/api/messages", b.handleMessages)
|
e.GET("/api/messages", b.handleMessages)
|
||||||
e.GET("/api/stream", b.handleStream)
|
e.GET("/api/stream", b.handleStream)
|
||||||
@ -82,6 +98,10 @@ func (b *API) handleHealthcheck(c echo.Context) error {
|
|||||||
return c.String(http.StatusOK, "OK")
|
return c.String(http.StatusOK, "OK")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Api) handleDocsRedirect(c echo.Context) error {
|
||||||
|
return c.Redirect(http.StatusMovedPermanently, "/swagger/index.html")
|
||||||
|
}
|
||||||
|
|
||||||
func (b *API) handlePostMessage(c echo.Context) error {
|
func (b *API) handlePostMessage(c echo.Context) error {
|
||||||
message := config.Message{}
|
message := config.Message{}
|
||||||
if err := c.Bind(&message); err != nil {
|
if err := c.Bind(&message); err != nil {
|
||||||
|
35
docs/docs.go
Normal file
35
docs/docs.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
||||||
|
// This file was generated by swaggo/swag at
|
||||||
|
// 2018-11-04 21:12:10.529569 +0800 CST m=+0.079119212
|
||||||
|
|
||||||
|
package docs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/swaggo/swag"
|
||||||
|
)
|
||||||
|
|
||||||
|
var doc = `{
|
||||||
|
"swagger": "2.0",
|
||||||
|
"info": {
|
||||||
|
"description": "A read/write API for the Matterbridge chat bridge.",
|
||||||
|
"title": "Matterbridge API",
|
||||||
|
"contact": {},
|
||||||
|
"license": {
|
||||||
|
"name": "Apache 2.0",
|
||||||
|
"url": "https://github.com/42wim/matterbridge/blob/master/LICENSE"
|
||||||
|
},
|
||||||
|
"version": "TODO"
|
||||||
|
},
|
||||||
|
"host": "TODO",
|
||||||
|
"basePath": "/api",
|
||||||
|
"paths": {}
|
||||||
|
}`
|
||||||
|
|
||||||
|
type s struct{}
|
||||||
|
|
||||||
|
func (s *s) ReadDoc() string {
|
||||||
|
return doc
|
||||||
|
}
|
||||||
|
func init() {
|
||||||
|
swag.Register(swag.Name, &s{})
|
||||||
|
}
|
16
docs/swagger/swagger.json
Normal file
16
docs/swagger/swagger.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"swagger": "2.0",
|
||||||
|
"info": {
|
||||||
|
"description": "A read/write API for the Matterbridge chat bridge.",
|
||||||
|
"title": "Matterbridge API",
|
||||||
|
"contact": {},
|
||||||
|
"license": {
|
||||||
|
"name": "Apache 2.0",
|
||||||
|
"url": "https://github.com/42wim/matterbridge/blob/master/LICENSE"
|
||||||
|
},
|
||||||
|
"version": "TODO"
|
||||||
|
},
|
||||||
|
"host": "TODO",
|
||||||
|
"basePath": "/api",
|
||||||
|
"paths": {}
|
||||||
|
}
|
12
docs/swagger/swagger.yaml
Normal file
12
docs/swagger/swagger.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
basePath: /api
|
||||||
|
host: TODO
|
||||||
|
info:
|
||||||
|
contact: {}
|
||||||
|
description: A read/write API for the Matterbridge chat bridge.
|
||||||
|
license:
|
||||||
|
name: Apache 2.0
|
||||||
|
url: https://github.com/42wim/matterbridge/blob/master/LICENSE
|
||||||
|
title: Matterbridge API
|
||||||
|
version: TODO
|
||||||
|
paths: {}
|
||||||
|
swagger: "2.0"
|
Loading…
x
Reference in New Issue
Block a user