cdn

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2022 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.3.0

type Client struct {
	HTTP *http.Client
	URL  string

	Service    string
	PublicKey  ed25519.PublicKey
	PrivateKey ed25519.PrivateKey
	// contains filtered or unexported fields
}

func (*Client) Download added in v0.3.0

func (cdn *Client) Download(name string) (io.Reader, error)

Download a file from the CDN.

func (*Client) Upload added in v0.3.0

func (cdn *Client) Upload(name string, file io.Reader) error

Upload a file to the CDN.

type Downloader

type Downloader interface {
	Download(name string) (io.Reader, error)
}

A Downloader retrieves a file by name.

type Service added in v0.3.0

type Service struct {
	Log   *zap.Logger
	Graph *ent.Client
	Auth  service.Authenticator
}

Service provides HTTP handlers for the CDN.

func (*Service) HTTP added in v0.3.0

func (svc *Service) HTTP(router *http.ServeMux)

HTTP registers http handlers for the CDN.

func (Service) HandleFileDownload added in v0.3.0

func (svc Service) HandleFileDownload(w http.ResponseWriter, r *http.Request) error

HandleFileDownload is an http.HandlerFunc which loads a file by name and serves it's content.

func (Service) HandleFileUpload added in v0.3.0

func (svc Service) HandleFileUpload(w http.ResponseWriter, r *http.Request) error

HandleFileUpload is an http.HandlerFunc which parses multipart forms and upserts file objects.

func (svc Service) HandleLink(w http.ResponseWriter, r *http.Request) error

HandleLink is an http.HandlerFunc which loads a file by its link and serves it's content.

type Uploader

type Uploader interface {
	Upload(name string, file io.Reader) error
}

An Uploader saves files by name. It is responsible for closing the file after writing if the file implements io.Closer.

Jump to

Keyboard shortcuts

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