endpoint

package
v0.0.0-...-2187358 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SC_ENDPOINT_PREFIX = "/soundcloud"

	SoundCloudPlaylistItem = "soundcloud#playlistItem"
	SoundCloudStreamItem   = "soundcloud#stream"
)
View Source
const (
	TWITCH_ENDPOINT_PREFIX   = "/twitch"
	TWITCH_RESULT_KIND_VIDEO = "twitch#video"
	TWITCH_RESULT_KIND_CLIP  = "twitch#clip"
)
View Source
const (
	YOUTUBE_ENDPOINT_PREFIX = "/youtube"

	YoutubePlaylistItem = "youtube#playlistItem"
	YoutubeSearchResult = "youtube#searchResult"
	YoutubeVideoKind    = "youtube#video"
)
View Source
const (
	AUTH_ENDPOINT_PREFIX = "/auth"
)
View Source
const STREAM_ENDPOINT_PREFIX = "/stream"

Variables

This section is empty.

Functions

func HandleEndpointError

func HandleEndpointError(err error, w http.ResponseWriter)

func HandleEndpointNotFound

func HandleEndpointNotFound(w http.ResponseWriter)

func HandleEndpointSuccess

func HandleEndpointSuccess(msg string, w http.ResponseWriter)

Types

type ApiEndpoint

type ApiEndpoint interface {
	// GetPath returns the full api request path for the current endpoint handler
	GetPath() string
	// Handle receives an array of url "segments", and an http writer and request.
	// "segments" are defined as a string slice consisting of each piece of the
	// api request path, minus the api request root ("/api/"). Hence for a request
	// path "/api/stream/verb/noun", the "segments" received would be:
	//   ["stream", "verb", "noun"].
	Handle(connection.ConnectionHandler, []string, http.ResponseWriter, *http.Request)
}

ApiEndpoint provides a REST handler for an api request

func NewAuthEndpoint

func NewAuthEndpoint() ApiEndpoint

func NewSoundCloudEndpoint

func NewSoundCloudEndpoint() ApiEndpoint

func NewStreamEndpoint

func NewStreamEndpoint() ApiEndpoint

func NewTwitchEndpoint

func NewTwitchEndpoint() ApiEndpoint

func NewYoutubeEndpoint

func NewYoutubeEndpoint() ApiEndpoint

type ApiEndpointSchema

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

func (*ApiEndpointSchema) GetPath

func (e *ApiEndpointSchema) GetPath() string

type ApiResponse

type ApiResponse struct {
	Message  string `json:"message,omitempty"`
	Error    string `json:"error,omitempty"`
	HTTPCode int    `json:"httpCode"`
}

type AuthEndpoint

type AuthEndpoint struct {
	*ApiEndpointSchema
}

AuthEndpoint implements ApiEndpoint

func (*AuthEndpoint) Handle

func (e *AuthEndpoint) Handle(connHandler connection.ConnectionHandler, segments []string, w http.ResponseWriter, r *http.Request)

sets a cookie with rbac roles from the given connection id

type EndpointResponseCodec

type EndpointResponseCodec interface {
	Decode([]byte) error
}

type EndpointResponseItem

type EndpointResponseItem struct {
	Kind  string `json:"kind"`
	Id    string `json:"id"`
	UId   string `json:"_id"`
	Thumb string `json:"thumb"`
	Url   string `json:"url"`
	Title string `json:"title"`
}

func (*EndpointResponseItem) Decode

func (i *EndpointResponseItem) Decode(b []byte) error

type SoundCloudEndpoint

type SoundCloudEndpoint struct {
	*ApiEndpointSchema
}

SoundCloudEndpoint implements ApiEndpoint

func (*SoundCloudEndpoint) Handle

func (e *SoundCloudEndpoint) Handle(connHandler connection.ConnectionHandler, segments []string, w http.ResponseWriter, r *http.Request)

Handle returns a "discovery" of all local streams in the server data root.

type SoundCloudEndpointError

type SoundCloudEndpointError struct {
	Message string `json:"error_message"`
}

type SoundCloudEndpointResponse

type SoundCloudEndpointResponse struct {
	Items []*SoundCloudItem `json:"items"`
}

type SoundCloudItem

type SoundCloudItem struct {
	*EndpointResponseItem

	Id        int    `json:"id"`
	Permalink string `json:"permalink_url"`
	Artwork   string `json:"artwork_url"`

	Errors []SoundCloudEndpointError `json:"errors"`
}

type SoundCloudPlaylist

type SoundCloudPlaylist struct {
	Tracks []*SoundCloudItem `json:"tracks"`
}

type StreamEndpoint

type StreamEndpoint struct {
	*ApiEndpointSchema
}

StreamEndpoint implements ApiEndpoint

func (*StreamEndpoint) Handle

func (e *StreamEndpoint) Handle(connHandler connection.ConnectionHandler, segments []string, w http.ResponseWriter, r *http.Request)

Handle returns a "discovery" of all local streams in the server data root.

type StreamList

type StreamList struct {
	Kind  string          `json:"kind"`
	Items []stream.Stream `json:"items"`
}

StreamList composes a slice of Stream

func (*StreamList) Serialize

func (s *StreamList) Serialize() ([]byte, error)

type TwitchClipItem

type TwitchClipItem struct {
	*EndpointResponseItem

	VideoId     string  `json:"slug"`
	Language    string  `json:"language"`
	Views       int     `json:"views"`
	PublishedAt string  `json:"created_at"`
	Duration    float64 `json:"duration"`
	Length      int     `json:"length"`
	Preview     string  `json:"animated_preview_url"`
	Game        string  `json:"game"`

	Thumbnails TwitchClipItemThumbnail `json:"thumbnails"`

	Vod TwitchClipItemVod `json:"vod"`
}

func (*TwitchClipItem) Decode

func (t *TwitchClipItem) Decode(b []byte) error

type TwitchClipItemThumbnail

type TwitchClipItemThumbnail struct {
	Medium string `json:"medium"`
}

type TwitchClipItemVod

type TwitchClipItemVod struct {
	Id  string `json:"id"`
	Url string `json:"url"`
}

type TwitchEndpoint

type TwitchEndpoint struct {
	*ApiEndpointSchema
}

TwitchEndpoint implements ApiEndpoint

func (*TwitchEndpoint) Handle

func (e *TwitchEndpoint) Handle(connHandler connection.ConnectionHandler, segments []string, w http.ResponseWriter, r *http.Request)

Handle returns a "discovery" of all local streams in the server data root.

type TwitchEndpointResponse

type TwitchEndpointResponse struct {
	Items interface{} `json:"items"`
}

type TwitchItem

type TwitchItem struct {
	*EndpointResponseItem

	Status      string                `json:"status"`
	Language    string                `json:"language"`
	Views       int                   `json:"views"`
	PublishedAt string                `json:"published_at"`
	Length      int                   `json:"length"`
	Preview     string                `json:"animated_preview_url"`
	Thumbnails  []TwitchItemThumbnail `json:"thumbnails"`
	Channel     TwitchItemChannel     `json:"channel"`
	VideoId     string                `json:"_id"`
	Game        string                `json:"game"`
}

func (*TwitchItem) Decode

func (t *TwitchItem) Decode(b []byte) error

type TwitchItemChannel

type TwitchItemChannel struct {
	Name        string `json:"name"`
	DisplayName string `json:"display_name"`
}

type TwitchItemCodec

type TwitchItemCodec func([]byte) ([]byte, error)

TwitchItemCodec receives bytes and returns an encoded TwitchItem

type TwitchItemThumbnail

type TwitchItemThumbnail struct {
	Url string `json:"url"`
}

type YoutubeEndpoint

type YoutubeEndpoint struct {
	*ApiEndpointSchema
}

YoutubeEndpoint implements ApiEndpoint

func (*YoutubeEndpoint) Handle

func (e *YoutubeEndpoint) Handle(connHandler connection.ConnectionHandler, segments []string, w http.ResponseWriter, r *http.Request)

Handle returns a "discovery" of all local streams in the server data root.

type YoutubeEndpointResponse

type YoutubeEndpointResponse struct {
	Items []*YoutubeItem `json:"items"`
}

func (*YoutubeEndpointResponse) Encode

func (r *YoutubeEndpointResponse) Encode() ([]byte, error)

type YoutubeItem

type YoutubeItem struct {
	*EndpointResponseItem

	Info    YoutubeItemInfo    `json:"info"`
	Snippet YoutubeItemSnippet `json:"snippet"`
}

type YoutubeItemInfo

type YoutubeItemInfo struct {
	Kind    string `json:"kind"`
	VideoId string `json:"videoId"`
}

holds an "id" struct for youtube videos

type YoutubeItemSnippet

type YoutubeItemSnippet struct {
	PublishedAt string                `json:"publishedAt"`
	ChannelId   string                `json:"channelId"`
	Title       string                `json:"title"`
	Description string                `json:"description"`
	PlaylistId  string                `json:"playlistId"`
	Thumbnails  YoutubeItemThumbnails `json:"thumbnails"`

	ResourceId YoutubeItemSnippetResource `json:"resourceId"`
}

type YoutubeItemSnippetResource

type YoutubeItemSnippetResource struct {
	Kind    string `json:"kind"`
	VideoId string `json:"videoId"`
}

type YoutubeItemThumbnail

type YoutubeItemThumbnail struct {
	Url    string `json:"url"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
}

type YoutubeItemThumbnails

type YoutubeItemThumbnails struct {
	Default  YoutubeItemThumbnail `json:"default"`
	Medium   YoutubeItemThumbnail `json:"medium"`
	High     YoutubeItemThumbnail `json:"high"`
	Standard YoutubeItemThumbnail `json:"standard"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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