Documentation
¶
Index ¶
- Variables
- func ClientIP(r *http.Request) string
- func LoggerMiddleware(logger *log.Logger) func(http.Handler) http.Handler
- func RenderHTML(w http.ResponseWriter, status int, s string) error
- func RenderJSON[T any](w http.ResponseWriter, status int, obj T) error
- type Details
- type HTTPServer
- func (s *HTTPServer) AddHandler() http.Handler
- func (s *HTTPServer) AddRoutes()
- func (s *HTTPServer) ClearHandler() http.Handler
- func (s *HTTPServer) NextHandler(peek bool) http.Handler
- func (s *HTTPServer) PlayNextHandler() http.Handler
- func (s *HTTPServer) QueueHandler() http.Handler
- func (s *HTTPServer) RemoveHandler() http.Handler
- func (s *HTTPServer) Start(ctx context.Context, timeoutSec int) error
- type Queue
- type ReqMetrics
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrQueueEmpty = fmt.Errorf("queue is empty") ErrQueueNoNext = fmt.Errorf("no more videos in queue") )
Functions ¶
func RenderHTML ¶
func RenderHTML(w http.ResponseWriter, status int, s string) error
func RenderJSON ¶
func RenderJSON[T any](w http.ResponseWriter, status int, obj T) error
func renderJSON[T any](w http.ResponseWriter, r *http.Request, status int, obj T) error {
Types ¶
type Details ¶
type HTTPServer ¶
type HTTPServer struct { Addr string Logger *log.Logger Queue *Queue TLSCertFile string TLSKeyFile string Handler http.Handler // Mux saves the http.ServeMux instance. This provides easier access to the // mux without having to enforce a ref type on HTTPServer.Handler everytime. // We can now use HTTPServer.Mux.Handle() instead of HTTPServer.Handler.(*http.ServeMux).Handle(). Mux *http.ServeMux }
func NewHTTPServer ¶
func (*HTTPServer) AddHandler ¶
func (s *HTTPServer) AddHandler() http.Handler
func (*HTTPServer) AddRoutes ¶
func (s *HTTPServer) AddRoutes()
func (*HTTPServer) ClearHandler ¶
func (s *HTTPServer) ClearHandler() http.Handler
func (*HTTPServer) NextHandler ¶
func (s *HTTPServer) NextHandler(peek bool) http.Handler
func (*HTTPServer) PlayNextHandler ¶
func (s *HTTPServer) PlayNextHandler() http.Handler
func (*HTTPServer) QueueHandler ¶
func (s *HTTPServer) QueueHandler() http.Handler
func (*HTTPServer) RemoveHandler ¶
func (s *HTTPServer) RemoveHandler() http.Handler
type ReqMetrics ¶
type ReqMetrics struct { ClientIP string `json:"client_ip"` RequestTime time.Time `json:"request_time"` Method string `json:"method"` URI string `json:"uri"` ResponseCode int `json:"response_code"` ResponseSize int64 `json:"response_size"` Referer string `json:"referer"` UserAgent string `json:"user_agent"` Duration time.Duration `json:"duration"` }
func NewReqMetrics ¶
func NewReqMetrics(r *http.Request) ReqMetrics
Click to show internal directories.
Click to hide internal directories.