api

package
v1.1.234 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiVersionMiddleware added in v1.1.37

func ApiVersionMiddleware(next http.Handler) http.Handler

ApiVersionMiddleware adds the API version information to the response header

func GetIP added in v1.0.51

func GetIP(r *http.Request) string

GetIP gets a requests IP address by reading off the forwarded-for header (for proxies) and falls back to use the remote address.

func ShowUI

func ShowUI(rw http.ResponseWriter, req *http.Request)

ShowUI redirects to the /ui/ url path

Types

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

ErrorResponse represents an API response

type PlayAudioRequest added in v1.0.44

type PlayAudioRequest struct {
	Endpoint string `json:"endpoint"`
}

PlayAudioRequest represents a request to play an audio endpoint

type Service

type Service struct {
	DB         *data.Manager
	StartTime  time.Time
	HistoryTTL time.Duration

	// PlayMedia signals a file should be played
	PlayMedia chan media.PlayAudioRequest

	// StopMedia signals a file should stop playing
	StopMedia chan string

	//	StopAllMedia signals all audio should stop playing
	StopAllMedia chan bool
}

Service encapsulates API service operations

func (Service) DeleteFile added in v1.0.20

func (service Service) DeleteFile(rw http.ResponseWriter, req *http.Request)

DeleteFile godoc @Summary Deletes a file in the system @Description Deletes a file in the system @Tags audio @Accept json @Produce json @Param id path string true "The file id to delete" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Failure 503 {object} api.ErrorResponse @Router /audio/{id} [delete]

func (Service) GetAllEvents added in v1.0.50

func (service Service) GetAllEvents(rw http.ResponseWriter, req *http.Request)

GetAllEvents godoc @Summary Gets all events in the system @Description Gets all events in the system @Tags events @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /events [get]

func (Service) GetEvent added in v1.0.50

func (service Service) GetEvent(rw http.ResponseWriter, req *http.Request)

GetEvent godoc @Summary Gets a log event. @Description Gets a log event. @Tags events @Accept json @Produce json @Param id path string true "The event id to get" @Success 200 {object} api.SystemResponse @Failure 404 {object} api.ErrorResponse @Router /event/{id} [get]

func (Service) ListAllFiles added in v1.0.20

func (service Service) ListAllFiles(rw http.ResponseWriter, req *http.Request)

ListAllFiles godoc @Summary List all files in the system @Description List all files in the system @Tags audio @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /audio [get]

func (Service) LoopAudio added in v1.1.37

func (service Service) LoopAudio(rw http.ResponseWriter, req *http.Request)

LoopAudio godoc @Summary Loop an audio file n times @Description Play an audio file over and over. (-1 to loop until stopped) @Tags audio @Accept json @Produce json @Param id path string true "The file id to play" @Param loopTimes path string true "The number of times to play. The value -1 will cause it to loop until stopped" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Failure 503 {object} api.ErrorResponse @Router /audio/loop/{id}/{loopTimes} [post]

func (Service) PlayAudio

func (service Service) PlayAudio(rw http.ResponseWriter, req *http.Request)

PlayAudio godoc @Summary Play an audio file @Description Play an audio file @Tags audio @Accept json @Produce json @Param id path string true "The file id to play" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Failure 503 {object} api.ErrorResponse @Router /audio/play/{id} [post]

func (Service) PlayRandomAudio added in v1.0.46

func (service Service) PlayRandomAudio(rw http.ResponseWriter, req *http.Request)

PlayRandomAudio godoc @Summary Play a random file already uploaded @Description Play a random file already uploaded @Tags audio @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /audio/play [post]

func (Service) StopAllAudio added in v1.0.46

func (service Service) StopAllAudio(rw http.ResponseWriter, req *http.Request)

StopAllAudio godoc @Summary Stops all audio 'play' processes @Description Stops all audio 'play' processes @Tags audio @Accept json @Produce json @Success 200 {object} api.SystemResponse @Router /audio/stop [post]

func (Service) StopAudio added in v1.0.31

func (service Service) StopAudio(rw http.ResponseWriter, req *http.Request)

StopAudio godoc @Summary Stops a specific audio file 'play' process @Description Stops a specific audio file 'play' process @Tags audio @Accept json @Produce json @Param pid path string true "The process id to stop" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Router /audio/stop/{pid} [post]

func (Service) StreamAudio added in v1.0.46

func (service Service) StreamAudio(rw http.ResponseWriter, req *http.Request)

StreamAudio godoc @Summary Stream from an audio endpoint @Description Stream from an audio endpoint @Tags audio @Accept json @Produce json @Param endpoint body api.PlayAudioRequest true "The endpoint url to stream" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 503 {object} api.ErrorResponse @Router /audio/stream [post]

func (Service) UploadFile added in v1.0.15

func (service Service) UploadFile(rw http.ResponseWriter, req *http.Request)

UploadFile godoc @Summary Upload a file @Description Upload file @Tags audio @Accept mpfd @Produce json @Param file formData file true "The file to upload" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 413 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /audio [put]

type SystemResponse

type SystemResponse struct {
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

SystemResponse is a response for a system request

Jump to

Keyboard shortcuts

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