-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
30 lines (25 loc) · 945 Bytes
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package gojam
import (
"fmt"
"net/http"
)
func init() {
http.HandleFunc("/spotify/authorization", spotifyAuthorizationHandler) //Getting the user's spotify authorization tokens
http.HandleFunc("/spotify/URI/", spotifyURIHandler) //Handling the URI redirect
}
/*
Redirecting to spotify after generating the authentication string basd on the values on gojam_constants
*/
func spotifyAuthorizationHandler(w http.ResponseWriter, r *http.Request) {
SpotifyAuthorizationRedirect(w,r);
}
/*
Handling the response code from spotify's redirect
StoreAuthResponse stores the code in our Values map
*/
func spotifyURIHandler(w http.ResponseWriter, r *http.Request) {
vals := ParseUrl(r.URL.String())
StoreAuthResponse(vals["/spotify/URI/?code"][0]);
SpotifyTokenRequest(w,r); //requesting the refresh and access tokesn
fmt.Fprintf(w, "spotifyURIHandler_code %v\n\n",Values["spotify_code"])
}