web

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PlayerHandleFunc

func PlayerHandleFunc(w http.ResponseWriter, r *http.Request)

Types

type AuthHandler

type AuthHandler struct {
	// Client is created as the result of Spotify backend calling auth callback,
	// as soon as spotify Client is created, the rest of the application can use
	// is to call any spotify apis.
	Client chan *spotify.Client

	// State is random string used in order to authenticate Client. It is used to
	// generate spotify backend URL to which user will be redirected. After user
	// comes back to the application (to the auth callback) it is used to verify
	// message received from the spotify backend.
	State string

	// used by auth callback to verify message from spotify backend
	// and to create a spotify Client.
	Authenticator SpotifyAuthenticatorInterface
}

func (*AuthHandler) ServeHTTP

func (s *AuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

authCallback is a function to by Spotify upon successful user login at their site

type SpotifyAuthenticatorInterface

type SpotifyAuthenticatorInterface interface {
	AuthURL(string) string
	Token(string, *http.Request) (*oauth2.Token, error)
	NewClient(*oauth2.Token) spotify.Client
}

type WebPlaybackReadyDevice

type WebPlaybackReadyDevice struct {
	DeviceId string
}

type WebPlaybackState

type WebPlaybackState struct {
	CurrentTrackName  string
	CurrentAlbumName  string
	CurrentArtistName string
}

type WebsocketHandler

type WebsocketHandler struct {
	// signal sent by the application to the websocket handler that triggers tear down
	// of websocket.
	PlayerShutdown chan bool

	// as soon as web player is ready it sends player device id as the very first
	// message on the websocket connection. Application may want to use this ID in
	// order to control on which player to play music (the one that it created, or
	// maybe on the other device that is also working)
	PlayerDeviceID chan spotify.ID

	// each time web player changes it's State it sens information about what is
	// currently played on the websocket
	PlayerStateChange chan *WebPlaybackState
}

func (*WebsocketHandler) ServeHTTP

func (s *WebsocketHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL