diff --git a/doc/REST-API.txt b/doc/REST-API.txt index 62d541f5..9a9be2a8 100644 --- a/doc/REST-API.txt +++ b/doc/REST-API.txt @@ -13,6 +13,32 @@ API or there was a problem while JSON encoding. Available end points with request methods and content-type: + /api/v1/config + + The config end points returns the server configuration. As it is available + to the Web client. + + GET application/x-www-form-urlencoded + No parameters. + Response 200: + { + "Title": "Spreed WebRTC", + "S": "static/ver=1399302670", + "B": "/", + "Token": "i-did-not-change-the-public-token-boo", + "StunURIs": [], + "TurnURIs": [ + "turn:myturnserver:443?transport=udp", + "turn:myturnserver:443?transport=tcp" + ], + "Tokens": false, + "Version": "0.17.5", + "UsersEnabled": true, + "UsersAllowRegistration": true, + "UsersMode": "certificate", + "Plugin": "" + } + /api/v1/tokens @@ -53,7 +79,8 @@ Available end points with request methods and content-type: /api/v1/sessions/{id}/ - A session id is passed in as subpath. Make sure to add the trailing slash (/). + A session id is passed in as subpath. Make sure to add the trailing + slash (/). PATCH application/json { diff --git a/src/app/spreed-speakfreely-server/config.go b/src/app/spreed-speakfreely-server/config.go index f3b4c2d3..313d0603 100644 --- a/src/app/spreed-speakfreely-server/config.go +++ b/src/app/spreed-speakfreely-server/config.go @@ -23,6 +23,7 @@ package main import ( "fmt" + "net/http" ) type Config struct { @@ -63,3 +64,7 @@ func NewConfig(title, ver, runtimeVersion, basePath, serverToken string, stunURI defaultRoomEnabled: defaultRoomEnabled, } } + +func (config *Config) Get(request *http.Request) (int, interface{}, http.Header) { + return 200, config, http.Header{"Content-Type": {"application/json; charset=utf-8"}} +} diff --git a/src/app/spreed-speakfreely-server/main.go b/src/app/spreed-speakfreely-server/main.go index bbb1c6a1..366aa0d4 100644 --- a/src/app/spreed-speakfreely-server/main.go +++ b/src/app/spreed-speakfreely-server/main.go @@ -376,6 +376,7 @@ func runner(runtime phoenix.Runtime) error { api := sleepy.NewAPI() api.SetMux(r.PathPrefix("/api/v1/").Subrouter()) api.AddResource(&Rooms{}, "/rooms") + api.AddResource(config, "/config") api.AddResourceWithWrapper(&Tokens{tokenProvider}, httputils.MakeGzipHandler, "/tokens") if usersEnabled { // Create Users handler.