github.com/turgay/mattermost-server@v5.3.2-0.20181002173352-2945e8a2b0ce+incompatible/api4/webrtc.go (about)

     1  // Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package api4
     5  
     6  import (
     7  	"net/http"
     8  )
     9  
    10  func (api *API) InitWebrtc() {
    11  	api.BaseRoutes.Webrtc.Handle("/token", api.ApiSessionRequired(webrtcToken)).Methods("GET")
    12  }
    13  
    14  func webrtcToken(c *Context, w http.ResponseWriter, r *http.Request) {
    15  	result, err := c.App.GetWebrtcInfoForSession(c.Session.Id)
    16  
    17  	if err != nil {
    18  		c.Err = err
    19  		return
    20  	}
    21  
    22  	w.Write([]byte(result.ToJson()))
    23  }