handler

package
v0.0.0-...-97fc41f Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Intents
	PlayPodcast       = "PlayPodcast"
	PlayLatestPodcast = "PlayLatestPodcast"
	PlayNthFromLatest = "PlayNthFromLatest"
	FastForward       = "FastForward"
	Rewind            = "Rewind"
	Pause             = "AMAZON.PauseIntent"
	Resume            = "AMAZON.ResumeIntent"

	// Events
	PlaybackNearlyFinished = "AudioPlayer.PlaybackNearlyFinished"
	PlaybackFinished       = "AudioPlayer.PlaybackFinished"

	// Directives
	DirPlay       = "AudioPlayer.Play"
	DirStop       = "AudioPlayer.Stop"
	DirClearQueue = "AudioPlayer.ClearQueue"
)

Alexa intents events and directives

Variables

This section is empty.

Functions

func ShiftPath

func ShiftPath(p string) (head, tail string)

ShiftPath splits off the first component of p, which will be cleaned of relative components before processing. head will never contain a slash and tail will always be a rooted path without trailing slash.

Types

type APIHandler

type APIHandler struct {
	// contains filtered or unexported fields
}

APIHandler handles calls to the syncapod api

func CreateAPIHandler

func CreateAPIHandler(dbClient db.Database) (*APIHandler, error)

CreateAPIHandler instatiates an APIHandler

func (*APIHandler) Alexa

func (h *APIHandler) Alexa(res http.ResponseWriter, req *http.Request)

Alexa handles all requests through /api/alexa endpoint

func (*APIHandler) AudioEvent

func (h *APIHandler) AudioEvent(res http.ResponseWriter, req *http.Request, body []byte)

AudioEvent handles responses from the Alexa audioplayer

func (*APIHandler) ServeHTTP

func (h *APIHandler) ServeHTTP(res http.ResponseWriter, req *http.Request)

ServeHTTP handles all requests throught /api/* endpoint

type AlexaArt

type AlexaArt struct {
	Sources []AlexaURL `json:"sources,omitempty"`
}

AlexaArt contains info for album art of stream

type AlexaAudioItem

type AlexaAudioItem struct {
	Stream   AlexaStream   `json:"stream,omitempty"`
	Metadata AlexaMetadata `json:"metadata,omitempty"`
}

AlexaAudioItem holds information of audio track

type AlexaAudioPlayer

type AlexaAudioPlayer struct {
	OffsetInMilliseconds int64  `json:"offsetInMilliseconds,omitempty"`
	Token                string `json:"token,omitempty"`
	PlayActivity         string `json:"playActivity,omitempty"`
}

AlexaAudioPlayer contains info of the currently played track if available

type AlexaContext

type AlexaContext struct {
	System      AlexaSystem      `json:"System,omitempty"`
	AudioPlayer AlexaAudioPlayer `json:"AudioPlayer,omitempty"`
}

AlexaContext contains system

type AlexaData

type AlexaData struct {
	Version string       `json:"version,omitempty"`
	Context AlexaContext `json:"context,omitempty"`
	Request AlexaRequest `json:"request,omitempty"`
}

AlexaData contains all the informatino and data from request sent from alexa

type AlexaDirective

type AlexaDirective struct {
	Type         string         `json:"type,omitempty"`
	PlayBehavior string         `json:"playBehavior,omitempty"`
	AudioItem    AlexaAudioItem `json:"audioItem,omitempty"`
}

AlexaDirective tells alexa what to do

type AlexaIntent

type AlexaIntent struct {
	Name       string     `json:"name,omitempty"`
	AlexaSlots AlexaSlots `json:"slots,omitempty"`
}

AlexaIntent holds information and data of intent sent from alexa

type AlexaMetadata

type AlexaMetadata struct {
	Title    string   `json:"title,omitempty"`
	Subtitle string   `json:"subtitle,omitempty"`
	Art      AlexaArt `json:"art,omitempty"`
}

AlexaMetadata contains information about the stream

type AlexaOutputSpeech

type AlexaOutputSpeech struct {
	Type         string `json:"type,omitempty"`
	Text         string `json:"text,omitempty"`
	PlayBehavior string `json:"playBehavior,omitempty"`
}

AlexaOutputSpeech takes type: "PlainText", text, and playBehavior: REPLACE_ENQUEUE

type AlexaPerson

type AlexaPerson struct {
	PersonID    string `json:"personId,omitempty"`
	AccessToken string `json:"accessToken,omitempty"`
}

AlexaPerson holds the info about the person who explicitly called the skill

type AlexaRequest

type AlexaRequest struct {
	Type                 string      `json:"type,omitempty"`
	RequestID            string      `json:"requestId,omitempty"`
	Timestamp            time.Time   `json:"timestamp,omitempty"`
	Token                string      `json:"token,omitempty"`
	OffsetInMilliseconds int64       `json:"offsetInMilliseconds,omitempty"`
	Intent               AlexaIntent `json:"intent,omitempty"`
}

AlexaRequest holds all the information and data

type AlexaResponse

type AlexaResponse struct {
	Directives       []AlexaDirective  `json:"directives,omitempty"`
	OutputSpeech     AlexaOutputSpeech `json:"outputSpeech,omitempty"`
	ShouldEndSession bool              `json:"shouldEndSession,omitempty"`
}

AlexaResponse contains the actual response

type AlexaResponseData

type AlexaResponseData struct {
	Version  string        `json:"version,omitempty"`
	Response AlexaResponse `json:"response,omitempty"`
}

AlexaResponseData contains the version and response

type AlexaSlot

type AlexaSlot struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

AlexaSlot holds information of the slot for the intent

type AlexaSlots

type AlexaSlots struct {
	Nth      AlexaSlot `json:"nth,omitempty"`
	Episode  AlexaSlot `json:"episode,omitempty"`
	Podcast  AlexaSlot `json:"podcast,omitempty"`
	Duration AlexaSlot `json:"duration,omitempty"`
}

AlexaSlots are the container for the slots

type AlexaStream

type AlexaStream struct {
	Token                string `json:"token,omitempty"`
	URL                  string `json:"url,omitempty"`
	OffsetInMilliseconds int64  `json:"offsetInMilliseconds,omitempty"`
}

AlexaStream contains information about the audio url and offset

type AlexaSystem

type AlexaSystem struct {
	Person AlexaPerson `json:"person,omitempty"`
	User   AlexaUser   `json:"user,omitempty"`
}

AlexaSystem is the container for person and user

type AlexaURL

type AlexaURL struct {
	URL    string `json:"url,omitempty"`
	Height int    `json:"height,omitempty"`
	Width  int    `json:"width,omitempty"`
}

AlexaURL is the container for AlexaArt

type AlexaUser

type AlexaUser struct {
	UserID      string `json:"userId,omitempty"`
	AccessToken string `json:"accessToken,omitempty"`
}

AlexaUser contains info about the user that holds the skill

type AudioAttributes

type AudioAttributes struct {
	Name                    string `json:"name,omitempty"`
	Codec                   string `json:"codec,omitempty"`
	SamplingRateInHertz     int64  `json:"samplingRateInHertz,omitempty"`
	DataRateInBitsPerSecond int64  `json:"dataRateInBitsPerSecond,omitempty"`
}

AudioAttributes contains the attributes of the AudioPayload & AudioReport

type AudioData

type AudioData struct {
	Event AudioEvent `json:"event,omitempty"`
}

AudioData is the container for AudioEvent

type AudioEvent

type AudioEvent struct {
	Header          AudioHeader   `json:"header,omitempty"`
	Payload         AudioPayload  `json:"payload,omitempty"`
	PlaybackReports []AudioReport `json:"playbackReports,omitempty"`
}

AudioEvent is the container for audioplayer response

type AudioHeader

type AudioHeader struct {
	Namespace string `json:"namespace,omitempty"`
	Name      string `json:"name,omitempty"`
	MessageID string `json:"messageId,omitempty"`
}

AudioHeader contains header info of AudioEvent

type AudioPayload

type AudioPayload struct {
	Token                string          `json:"token,omitempty"`
	OffsetInMilliseconds int64           `json:"offsetInMilliseconds,omitempty"`
	PlaybackAttributes   AudioAttributes `json:"playbackAttributes,omitempty"`
}

AudioPayload contains the main info of AudioEvent

type AudioReport

type AudioReport struct {
	StartOffsetInMilliseconds string          `json:"startOffsetInMilliseconds,omitempty"`
	EndOffsetInMilliseconds   string          `json:"endOffsetInMilliseconds,omitempty"`
	PlaybackAttributes        AudioAttributes `json:"playbackAttributes,omitempty"`
}

AudioReport contains playback info for AudioEvent

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is the main handler for syncapod, all routes go through it

func CreateHandler

func CreateHandler(dbClient db.Database, config *config.Config) (*Handler, error)

CreateHandler sets up the main handler

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(res http.ResponseWriter, req *http.Request)

ServeHTTP handles all requests

type OauthHandler

type OauthHandler struct {
	// contains filtered or unexported fields
}

OauthHandler handles authorization and authentication to oauth clients

func CreateOauthHandler

func CreateOauthHandler(dbClient db.Database, clientID, clientSecret string) (*OauthHandler, error)

CreateOauthHandler just intantiates an OauthHandler

func (*OauthHandler) Authorize

func (h *OauthHandler) Authorize(res http.ResponseWriter, req *http.Request)

Authorize takes a session(access) token and validates it and sents back user info

func (*OauthHandler) Get

func (h *OauthHandler) Get(res http.ResponseWriter, req *http.Request)

Get is the handler for /api/oauth

func (*OauthHandler) Login

func (h *OauthHandler) Login(res http.ResponseWriter, req *http.Request)

Login handles the post and get request of a login page

func (*OauthHandler) Post

func (h *OauthHandler) Post(res http.ResponseWriter, req *http.Request)

Post hanldes all post request at the oauth endpoint

func (*OauthHandler) ServeHTTP

func (h *OauthHandler) ServeHTTP(res http.ResponseWriter, req *http.Request)

func (*OauthHandler) Token

func (h *OauthHandler) Token(res http.ResponseWriter, req *http.Request)

Token handles authenticating the oauth client with the given token

Jump to

Keyboard shortcuts

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