api

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MimeJSON = "application/json"
	MimeText = "text/plain"
)
View Source
const StreamNotFound = "stream not found"

Variables

View Source
var Handler http.Handler
View Source
var Port int

Functions

func Error added in v1.7.0

func Error(w http.ResponseWriter, err error)

func HandleFunc

func HandleFunc(pattern string, handler http.HandlerFunc)

HandleFunc handle pattern with relative path: - "api/streams" => "{basepath}/api/streams" - "/streams" => "/streams"

func Init

func Init()

func Response added in v1.6.0

func Response(w http.ResponseWriter, body any, contentType string)

func ResponseJSON added in v1.6.0

func ResponseJSON(w http.ResponseWriter, v any)

ResponseJSON important always add Content-Type so go won't need to call http.DetectContentType

func ResponsePrettyJSON added in v1.6.0

func ResponsePrettyJSON(w http.ResponseWriter, v any)

func ResponseSources added in v1.7.0

func ResponseSources(w http.ResponseWriter, sources []*Source)

Types

type Source added in v1.7.0

type Source struct {
	ID       string `json:"id,omitempty"`
	Name     string `json:"name,omitempty"`
	Info     string `json:"info,omitempty"`
	URL      string `json:"url,omitempty"`
	Location string `json:"location,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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