Browse Source

Added API end point to receive the server config document.

pull/28/head
Simon Eisenmann 11 years ago
parent
commit
d04fbb9a2c
  1. 29
      doc/REST-API.txt
  2. 5
      src/app/spreed-speakfreely-server/config.go
  3. 1
      src/app/spreed-speakfreely-server/main.go

29
doc/REST-API.txt

@ -13,6 +13,32 @@ API or there was a problem while JSON encoding. @@ -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: @@ -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
{

5
src/app/spreed-speakfreely-server/config.go

@ -23,6 +23,7 @@ package main @@ -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 @@ -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"}}
}

1
src/app/spreed-speakfreely-server/main.go

@ -376,6 +376,7 @@ func runner(runtime phoenix.Runtime) error { @@ -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.

Loading…
Cancel
Save