path

package
v0.0.0-...-2187358 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ApiRootUrl    = "/api"
	FileRootUrl   = "/src/static/"
	SocketRootUrl = "/ws"
	RoomRootUrl   = "/room"
	StreamRootUrl = "/stream"

	RoomRootPrefix = "/v/"

	RoomRootRegex   = "^\\/v\\/.*"
	StreamRootRegex = "^\\/s\\/.*"

	StreamDataRootPath = "data"
	FileRootPath       = "pkg/webclient"
)
View Source
var (
	RootPathUrl       = "/"
	RootPathIndexFile = "index.html"
)
View Source
var (
	RoomPathIndexFile = "video.html"
)

Functions

func FileExtensionFromFilePath

func FileExtensionFromFilePath(fpath string) string

func FileMimeFromFilePath

func FileMimeFromFilePath(fpath string) (string, error)

func FilePathFromFilename

func FilePathFromFilename(fname string) string

func FilePathFromRequest

func FilePathFromRequest(r *http.Request) string

func FilePathFromUrl

func FilePathFromUrl(url string) string

func HandleInvalidRange

func HandleInvalidRange(msg string, w http.ResponseWriter, r *http.Request)

func HandleNotFound

func HandleNotFound(url string, w http.ResponseWriter, r *http.Request)

func HandleServerError

func HandleServerError(url string, w http.ResponseWriter, r *http.Request)

func RedirectHome

func RedirectHome(url string, w http.ResponseWriter, r *http.Request)

func StreamDataFilePathFromFilename

func StreamDataFilePathFromFilename(fname string) string

func StreamDataFilePathFromUrl

func StreamDataFilePathFromUrl(url string) string

func StreamDataFilenameFromUrl

func StreamDataFilenameFromUrl(url string) string

StreamDataFilenameFromUrl receives a stream-formatted request url and returns its last segment, or the original url if the path is malformed.

Types

type Path

type Path interface {
	// GetUrl returns the fully-qualified url of an http url handler
	GetUrl() string
	// Handle receives an http writer and http request and
	// responds to the request with the appropriate resources / response.
	// an error is returned if the request is not able to be handled.
	Handle(string, http.ResponseWriter, *http.Request) error
}

Path is an interface representing an http url handler

func NewPathRoom

func NewPathRoom() Path

func NewPathRoot

func NewPathRoot() Path

func NewPathStream

func NewPathStream() Path

type PathHandler

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

PathHandler implements Path and provides default path-handling values

func (PathHandler) GetUrl

func (h PathHandler) GetUrl() string

func (PathHandler) Handle

func (h PathHandler) Handle(url string, w http.ResponseWriter, r *http.Request) error

type RoomPathHandler

type RoomPathHandler struct {
	*PathHandler
}

RoomPathHandler implements Path and handles all room url requests

func (*RoomPathHandler) Handle

func (h *RoomPathHandler) Handle(url string, w http.ResponseWriter, r *http.Request) error

type RootPathHandler

type RootPathHandler struct {
	*PathHandler
}

RootPathHandler implements Path and handles all root url requests

func (*RootPathHandler) Handle

func (h *RootPathHandler) Handle(url string, w http.ResponseWriter, r *http.Request) error

type StreamPathHandler

type StreamPathHandler struct {
	*PathHandler
}

RoomPathHandler implements Path and handles all room url requests

func (*StreamPathHandler) Handle

Jump to

Keyboard shortcuts

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