api

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubStreamStatus = "status"
	SubStreamEvents = "events"
)

Variables

View Source
var IndexInstance = NewIndex()

Functions

func HandleStopGame

func HandleStopGame(platform platforms.Platform) http.HandlerFunc

func RunApiServer

func RunApiServer(
	pl platforms.Platform,
	cfg *config.UserConfig,
	st *state.State,
	tq *tokens.TokenQueue,
	db *database.Database,
)

Types

type AddMappingRequest

type AddMappingRequest struct {
	Label    string `json:"label"`
	Enabled  bool   `json:"enabled"`
	Type     string `json:"type"`
	Match    string `json:"match"`
	Pattern  string `json:"pattern"`
	Override string `json:"override"`
}

func (*AddMappingRequest) Bind

func (amr *AddMappingRequest) Bind(r *http.Request) error

type AllMappingsResponse

type AllMappingsResponse struct {
	Mappings []MappingResponse `json:"mappings"`
}

func (*AllMappingsResponse) Render

type HistoryReponseEntry

type HistoryReponseEntry struct {
	Time    time.Time `json:"time"`
	Type    string    `json:"type"`
	UID     string    `json:"uid"`
	Text    string    `json:"text"`
	Data    string    `json:"data"`
	Success bool      `json:"success"`
}

type HistoryResponse

type HistoryResponse struct {
	Entries []HistoryReponseEntry `json:"entries"`
}

func (*HistoryResponse) Render

type Index

type Index struct {
	Indexing    bool
	TotalSteps  int
	CurrentStep int
	CurrentDesc string
	TotalFiles  int
	// contains filtered or unexported fields
}

func NewIndex

func NewIndex() *Index

func (*Index) Exists

func (s *Index) Exists(platform platforms.Platform) bool

func (*Index) GenerateIndex

func (s *Index) GenerateIndex(platform platforms.Platform, cfg *config.UserConfig)

func (*Index) SetEventHook

func (s *Index) SetEventHook(hook *func(st *Index))

type IndexResponse

type IndexResponse struct {
	Exists      bool   `json:"exists"`
	Indexing    bool   `json:"indexing"`
	TotalSteps  int    `json:"totalSteps"`
	CurrentStep int    `json:"currentStep"`
	CurrentDesc string `json:"currentDesc"`
	TotalFiles  int    `json:"totalFiles"`
}

type LaunchRequest

type LaunchRequest struct {
	Type     string                 `json:"type"`
	UID      string                 `json:"uid"`
	Text     string                 `json:"text"`
	Data     string                 `json:"data"`
	Metadata *LaunchRequestMetadata `json:"metadata"`
}

func (*LaunchRequest) Bind

func (lr *LaunchRequest) Bind(r *http.Request) error

type LaunchRequestMetadata

type LaunchRequestMetadata struct {
	ToyModel *string `json:"toyModel"`
}

type MappingResponse

type MappingResponse struct {
	database.Mapping
	Added string `json:"added"`
}

type PlayingResponse

type PlayingResponse struct {
	System     string `json:"system"`
	SystemName string `json:"systemName"`
	Game       string `json:"game"`
	GameName   string `json:"gameName"`
	GamePath   string `json:"gamePath"`
}

type ReaderResponse

type ReaderResponse struct {
	// TODO: type
	Connected bool   `json:"connected"`
	Device    string `json:"device"`
	Info      string `json:"info"`
}

type ReaderStatusResponse

type ReaderStatusResponse struct {
	Connected bool   `json:"connected"`
	Type      string `json:"type"`
}

TODO: legacy, remove in v2

type ReaderWriteRequest

type ReaderWriteRequest struct {
	Text string `json:"text"`
}

func (*ReaderWriteRequest) Bind

func (rwr *ReaderWriteRequest) Bind(r *http.Request) error

type SearchResultGame

type SearchResultGame struct {
	System System `json:"system"`
	Name   string `json:"name"`
	Path   string `json:"path"`
}

type SearchResults

type SearchResults struct {
	Results []SearchResultGame `json:"results"`
	Total   int                `json:"total"`
}

func (*SearchResults) Render

func (sr *SearchResults) Render(w http.ResponseWriter, r *http.Request) error

type SettingsResponse

type SettingsResponse struct {
	ConnectionString  string   `json:"connectionString"`
	AllowCommands     bool     `json:"allowCommands"`
	DisableSounds     bool     `json:"disableSounds"`
	ProbeDevice       bool     `json:"probeDevice"`
	ExitGame          bool     `json:"exitGame"`
	ExitGameDelay     int8     `json:"exitGameDelay"`
	ExitGameBlocklist []string `json:"exitGameBlocklist"`
	Debug             bool     `json:"debug"`
	Launching         bool     `json:"launching"`
}

func (*SettingsResponse) Render

type StatusResponse

type StatusResponse struct {
	Reader      ReaderStatusResponse `json:"reader"` // TODO: remove in v2
	Readers     []ReaderResponse     `json:"readers"`
	ActiveToken TokenResponse        `json:"activeToken"`
	LastToken   TokenResponse        `json:"lastToken"`
	Launching   bool                 `json:"launching"`
	GamesIndex  IndexResponse        `json:"gamesIndex"`
	Playing     PlayingResponse      `json:"playing"`
}

func (*StatusResponse) Render

func (sr *StatusResponse) Render(w http.ResponseWriter, r *http.Request) error

type System

type System struct {
	Id       string `json:"id"`
	Name     string `json:"name"`
	Category string `json:"category"`
}

type SystemsResponse

type SystemsResponse struct {
	Systems []System `json:"systems"`
}

func (*SystemsResponse) Render

type TokenResponse

type TokenResponse struct {
	Type     string    `json:"type"`
	UID      string    `json:"uid"`
	Text     string    `json:"text"`
	Data     string    `json:"data"`
	ScanTime time.Time `json:"scanTime"`
}

type UpdateMappingRequest

type UpdateMappingRequest struct {
	Label    *string `json:"label"`
	Enabled  *bool   `json:"enabled"`
	Type     *string `json:"type"`
	Match    *string `json:"match"`
	Pattern  *string `json:"pattern"`
	Override *string `json:"override"`
}

func (*UpdateMappingRequest) Bind

func (umr *UpdateMappingRequest) Bind(r *http.Request) error

type UpdateSettingsRequest

type UpdateSettingsRequest struct {
	ConnectionString  *string   `json:"connectionString"`
	AllowCommands     *bool     `json:"allowCommands"`
	DisableSounds     *bool     `json:"disableSounds"`
	ProbeDevice       *bool     `json:"probeDevice"`
	ExitGame          *bool     `json:"exitGame"`
	ExitGameDelay     *int8     `json:"exitGameDelay"`
	ExitGameBlocklist *[]string `json:"exitGameBlocklist"`
	Debug             *bool     `json:"debug"`
	Launching         *bool     `json:"launching"`
}

func (*UpdateSettingsRequest) Bind

func (usr *UpdateSettingsRequest) Bind(r *http.Request) error

type VersionResponse

type VersionResponse struct {
	Version  string `json:"version"`
	Platform string `json:"platform"`
}

func (*VersionResponse) Render

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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