RunCallbackServer creates a web server running on the port defined in the configuration file under the spotify. callback_url field. A pointer to the server object is returned so that it can be shutdown when no longer needed.
()
| 56 | // callback_url field. |
| 57 | // A pointer to the server object is returned so that it can be shutdown when no longer needed. |
| 58 | func (s *RealDiskplayerServer) RunCallbackServer() (*http.Server, error) { |
| 59 | r := ConfigValue(SPOTIFY_CALLBACK_URL) |
| 60 | u, err := url.Parse(r) |
| 61 | if err != nil { |
| 62 | return nil, err |
| 63 | } |
| 64 | |
| 65 | http.Handle(u.EscapedPath(), s.cbh) |
| 66 | http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { |
| 67 | log.Println("Got request for:", r.URL.String()) |
| 68 | }) |
| 69 | server := &http.Server{Addr: ":" + u.Port(), Handler: nil} |
| 70 | go server.ListenAndServe() |
| 71 | return server, nil |
| 72 | } |
| 73 | |
| 74 | func (s *RealDiskplayerServer) TokenChannel() chan *oauth2.Token { |
| 75 | return s.cbh.ch |
nothing calls this directly
no test coverage detected