Documentation ¶
Index ¶
- Constants
- Variables
- func Error(w http.ResponseWriter, err error)
- func HandleFunc(pattern string, handler http.HandlerFunc)
- func Init()
- func Response(w http.ResponseWriter, body any, contentType string)
- func ResponseJSON(w http.ResponseWriter, v any)
- func ResponsePrettyJSON(w http.ResponseWriter, v any)
- func ResponseSources(w http.ResponseWriter, sources []*Source)
- type Source
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 ¶
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 ResponseJSON ¶
func ResponseJSON(w http.ResponseWriter, v any)
ResponseJSON important always add Content-Type so go won't need to call http.DetectContentType
func ResponsePrettyJSON ¶
func ResponsePrettyJSON(w http.ResponseWriter, v any)
func ResponseSources ¶
func ResponseSources(w http.ResponseWriter, sources []*Source)
Types ¶
Click to show internal directories.
Click to hide internal directories.