Added loose docs for each endpoint.
This commit is contained in:
parent
b9d6c06c82
commit
de00b56d9a
@ -16,13 +16,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// @title Matterbridge API
|
// @title Matterbridge API
|
||||||
// @version TODO
|
|
||||||
// @description A read/write API for the Matterbridge chat bridge.
|
// @description A read/write API for the Matterbridge chat bridge.
|
||||||
|
|
||||||
// @license.name Apache 2.0
|
// @license.name Apache 2.0
|
||||||
// @license.url https://github.com/42wim/matterbridge/blob/master/LICENSE
|
// @license.url https://github.com/42wim/matterbridge/blob/master/LICENSE
|
||||||
|
|
||||||
// @host TODO
|
// TODO @host
|
||||||
// @basePath /api
|
// @basePath /api
|
||||||
|
|
||||||
type API struct {
|
type API struct {
|
||||||
@ -39,6 +38,9 @@ type Message struct {
|
|||||||
Gateway string `json:"gateway"`
|
Gateway string `json:"gateway"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @securityDefinitions.apikey
|
||||||
|
// @in header
|
||||||
|
// @name Authorization
|
||||||
func New(cfg *bridge.Config) bridge.Bridger {
|
func New(cfg *bridge.Config) bridge.Bridger {
|
||||||
b := &API{Config: cfg}
|
b := &API{Config: cfg}
|
||||||
e := echo.New()
|
e := echo.New()
|
||||||
@ -102,6 +104,12 @@ func (b *Api) handleDocsRedirect(c echo.Context) error {
|
|||||||
return c.Redirect(http.StatusMovedPermanently, "/swagger/index.html")
|
return c.Redirect(http.StatusMovedPermanently, "/swagger/index.html")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handlePostMessage godoc
|
||||||
|
// @Summary Create/Update a message
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {object} config.Message
|
||||||
|
// @Router /message [post]
|
||||||
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 {
|
||||||
@ -118,6 +126,11 @@ func (b *API) handlePostMessage(c echo.Context) error {
|
|||||||
return c.JSON(http.StatusOK, message)
|
return c.JSON(http.StatusOK, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleMessages godoc
|
||||||
|
// @Summary Lists messages
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {array} config.Message
|
||||||
|
// @Router /messages [get]
|
||||||
func (b *API) handleMessages(c echo.Context) error {
|
func (b *API) handleMessages(c echo.Context) error {
|
||||||
b.Lock()
|
b.Lock()
|
||||||
defer b.Unlock()
|
defer b.Unlock()
|
||||||
@ -126,6 +139,11 @@ func (b *API) handleMessages(c echo.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleStream godoc
|
||||||
|
// @Summary Streams realtime messages
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {object} config.Message
|
||||||
|
// @Router /stream [get]
|
||||||
func (b *API) handleStream(c echo.Context) error {
|
func (b *API) handleStream(c echo.Context) error {
|
||||||
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
|
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
|
||||||
c.Response().WriteHeader(http.StatusOK)
|
c.Response().WriteHeader(http.StatusOK)
|
||||||
|
115
docs/docs.go
115
docs/docs.go
@ -1,6 +1,6 @@
|
|||||||
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
||||||
// This file was generated by swaggo/swag at
|
// This file was generated by swaggo/swag at
|
||||||
// 2018-11-04 21:12:10.529569 +0800 CST m=+0.079119212
|
// 2018-11-05 01:51:14.853722 +0800 CST m=+0.078800065
|
||||||
|
|
||||||
package docs
|
package docs
|
||||||
|
|
||||||
@ -17,12 +17,117 @@ var doc = `{
|
|||||||
"license": {
|
"license": {
|
||||||
"name": "Apache 2.0",
|
"name": "Apache 2.0",
|
||||||
"url": "https://github.com/42wim/matterbridge/blob/master/LICENSE"
|
"url": "https://github.com/42wim/matterbridge/blob/master/LICENSE"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"version": "TODO"
|
|
||||||
},
|
|
||||||
"host": "TODO",
|
|
||||||
"basePath": "/api",
|
"basePath": "/api",
|
||||||
"paths": {}
|
"paths": {
|
||||||
|
"/message": {
|
||||||
|
"post": {
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"summary": "Create/Update a message",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"$ref": "#/definitions/config.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/messages": {
|
||||||
|
"get": {
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"summary": "Lists messages",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/config.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/stream": {
|
||||||
|
"get": {
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"summary": "Streams realtime messages",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"$ref": "#/definitions/config.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"definitions": {
|
||||||
|
"config.Message": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"account": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"avatar": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"channel": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"event": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"gateway": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"protocol": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"userid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"username": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securityDefinitions": {
|
||||||
|
"": {
|
||||||
|
"type": "apiKey",
|
||||||
|
"name": "Authorization",
|
||||||
|
"in": "header"
|
||||||
|
}
|
||||||
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
type s struct{}
|
type s struct{}
|
||||||
|
@ -7,10 +7,115 @@
|
|||||||
"license": {
|
"license": {
|
||||||
"name": "Apache 2.0",
|
"name": "Apache 2.0",
|
||||||
"url": "https://github.com/42wim/matterbridge/blob/master/LICENSE"
|
"url": "https://github.com/42wim/matterbridge/blob/master/LICENSE"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"version": "TODO"
|
|
||||||
},
|
|
||||||
"host": "TODO",
|
|
||||||
"basePath": "/api",
|
"basePath": "/api",
|
||||||
"paths": {}
|
"paths": {
|
||||||
|
"/message": {
|
||||||
|
"post": {
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"summary": "Create/Update a message",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"$ref": "#/definitions/config.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/messages": {
|
||||||
|
"get": {
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"summary": "Lists messages",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/config.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/stream": {
|
||||||
|
"get": {
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"summary": "Streams realtime messages",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"$ref": "#/definitions/config.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"definitions": {
|
||||||
|
"config.Message": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"account": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"avatar": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"channel": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"event": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"gateway": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"protocol": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"userid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"username": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"securityDefinitions": {
|
||||||
|
"": {
|
||||||
|
"type": "apiKey",
|
||||||
|
"name": "Authorization",
|
||||||
|
"in": "header"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,5 +1,32 @@
|
|||||||
basePath: /api
|
basePath: /api
|
||||||
host: TODO
|
definitions:
|
||||||
|
config.Message:
|
||||||
|
properties:
|
||||||
|
account:
|
||||||
|
type: string
|
||||||
|
avatar:
|
||||||
|
type: string
|
||||||
|
channel:
|
||||||
|
type: string
|
||||||
|
event:
|
||||||
|
type: string
|
||||||
|
extra:
|
||||||
|
type: object
|
||||||
|
gateway:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
protocol:
|
||||||
|
type: string
|
||||||
|
text:
|
||||||
|
type: string
|
||||||
|
timestamp:
|
||||||
|
type: string
|
||||||
|
userid:
|
||||||
|
type: string
|
||||||
|
username:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
info:
|
info:
|
||||||
contact: {}
|
contact: {}
|
||||||
description: A read/write API for the Matterbridge chat bridge.
|
description: A read/write API for the Matterbridge chat bridge.
|
||||||
@ -7,6 +34,46 @@ info:
|
|||||||
name: Apache 2.0
|
name: Apache 2.0
|
||||||
url: https://github.com/42wim/matterbridge/blob/master/LICENSE
|
url: https://github.com/42wim/matterbridge/blob/master/LICENSE
|
||||||
title: Matterbridge API
|
title: Matterbridge API
|
||||||
version: TODO
|
paths:
|
||||||
paths: {}
|
/message:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/config.Message'
|
||||||
|
type: object
|
||||||
|
summary: Create/Update a message
|
||||||
|
/messages:
|
||||||
|
get:
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/config.Message'
|
||||||
|
type: array
|
||||||
|
summary: Lists messages
|
||||||
|
/stream:
|
||||||
|
get:
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/config.Message'
|
||||||
|
type: object
|
||||||
|
summary: Streams realtime messages
|
||||||
|
securityDefinitions:
|
||||||
|
"":
|
||||||
|
in: header
|
||||||
|
name: Authorization
|
||||||
|
type: apiKey
|
||||||
swagger: "2.0"
|
swagger: "2.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user