MCPcopy Create free account
hub / github.com/dinofizz/diskplayer / RunCallbackServer

Method RunCallbackServer

server.go:58–72  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

56// callback_url field.
57// A pointer to the server object is returned so that it can be shutdown when no longer needed.
58func (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
74func (s *RealDiskplayerServer) TokenChannel() chan *oauth2.Token {
75 return s.cbh.ch

Callers

nothing calls this directly

Calls 1

ConfigValueFunction · 0.85

Tested by

no test coverage detected