httpService

package
v7.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 18 Imported by: 4

Documentation

Index

Constants

View Source
const ContentTypeJSON = `application/json`
View Source
const ContentTypeM3U8 = `application/x-mpegURL`
View Source
const ContentTypeTS = `video/MP2T`
View Source
const LiveM3U8MinDuration = time.Duration(40) * time.Second // TODO make configurable

LiveM3U8MinDuration is used to govern the minimum number of seconds to be present in a live m2u8

View Source
const LiveM3U8MinFiles = 20 // TODO make configurable

LiveM3U8MinFiles is used to govern the minimum number of files to be present in a live m3u8

Variables

This section is empty.

Functions

func AddFullDefaultHeader

func AddFullDefaultHeader(w http.ResponseWriter, r *http.Request, newKey string, newVals []string) bool

func GenerateETag

func GenerateETag(source string) string

func GetRoutes

func GetRoutes(cfg endpoint.Config) (map[string]EndpointRoutes, error)

GetRoutes returns the map of config IDs, to the full HTTP paths, e.g. for each m3u8 and ts created for that config object.

func ParseHTTPDate

func ParseHTTPDate(d string) (time.Time, bool)

ParseHTTPDate parses the given RFC7231§7.1.1 HTTP-date

func PrintRoutes

func PrintRoutes(w io.Writer, routes map[string]EndpointRoutes, endpointPrefix, routePrefix string, showFragments bool)

PrintRoutes writes the routes across multiple lines in human-readable format to the given writer. The header is written at the beginning of each endpoint. The routePrefix is written at the beginning of each route. If showFragments is false, only manifests and meta files are printed, not video fragments.

func StartHTTPListener

func StartHTTPListener(conf endpoint.Config, routes map[string]EndpointRoutes) error

StartHTTPListener kicks off the HTTPS stack

func StartHTTPSListener

func StartHTTPSListener(conf endpoint.Config, routes map[string]EndpointRoutes) error

StartHTTPSListener kicks off the HTTPS stack

Types

type BodyInterceptor

type BodyInterceptor struct {
	// contains filtered or unexported fields
}

BodyInterceptor is a container for a http writer body so we can write headers after the real writes are issued

func (*BodyInterceptor) Body

func (i *BodyInterceptor) Body() []byte

Body is used for interface compatability with http response writer

func (*BodyInterceptor) Header

func (i *BodyInterceptor) Header() http.Header

Header is used for interface compatability with http response writer

func (*BodyInterceptor) RealWrite

func (i *BodyInterceptor) RealWrite() (int, error)

RealWrite is called to perform the actual write operation already done further in the chain

func (*BodyInterceptor) Write

func (i *BodyInterceptor) Write(b []byte) (int, error)

Write is used for interface compatability with http response writer

func (*BodyInterceptor) WriteHeader

func (i *BodyInterceptor) WriteHeader(rc int)

WriteHeader doesn't actually write a header, just a response code. Thanks go.

type EndpointRoutes

type EndpointRoutes struct {
	MasterPath    string
	VariantPaths  []string
	FragmentPaths []string
	MetaJSONPaths []string
	IsABR         bool
}

EndpointRoutes contains the paths of all HTTP routes for a given config "endpoint" TODO come up with a better structure. The static and abr checks are hackish, the structure should only contain the necessary variables for the given route. Maybe there's a better way with interfaces?

Jump to

Keyboard shortcuts

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