cdn

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderIfNoneMatch = "If-None-Match"
	HeaderEtag        = "Etag"
)

HeaderIfNoneMatch is the name of the header the client should set if they wish to only download the file if it has been modified since the provided hash. HeaderEtag is set by the server to the hash of the downloaded file.

View Source
const DefaultMaxUploadSize = 10 << 20

DefaultMaxUploadSize defines the maximum number of bytes an uploaded file can be.

Variables

View Source
var (
	ErrInvalidFileName    = errors.NewHTTP("invalid file name provided", http.StatusBadRequest)
	ErrInvalidFileContent = errors.NewHTTP("invalid file content provided", http.StatusBadRequest)
	ErrFileNotModified    = errors.NewHTTP("file has not been modified", http.StatusNotModified)
	ErrFileNotFound       = errors.NewHTTP("file not found", http.StatusNotFound)
)

ErrInvalidFileName occurs when an invalid file name is provided to the API. ErrInvalidFileContent occurs when an upload is attempted with invalid file content. ErrFileNotModified occurs when a download is attempted using the If-None-Match header and the file has not been modified. ErrFileNotFound occurs when a download is attempted for a file that does not exist.

Functions

func NewDownloadHandler

func NewDownloadHandler(graph *ent.Client, prefix string) http.Handler

NewDownloadHandler returns an HTTP handler responsible for downloading a file from the CDN.

func NewUploadHandler

func NewUploadHandler(graph *ent.Client) http.Handler

NewUploadHandler returns an HTTP handler responsible for uploading a file to the CDN.

Types

This section is empty.

Jump to

Keyboard shortcuts

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