archiveserver

package
v2.6.0-nightly.20230503 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package archiveserver implements an HTTP server for downloading archives.

See: https://www.notion.so/2023-04-03-HTTP-file-and-archive-downloads-cfb56fac16e54957b015070416b09e94

Index

Constants

View Source
const (
	EncodingVersion1 = uint8(0x01)
)

Variables

This section is empty.

Functions

func CSRFWrapper

func CSRFWrapper(h http.Handler) http.HandlerFunc

CSRFWrapper is an http.Handler that provides CSRF protection to the underlying handler.

func Decode

func Decode(r io.Reader) (io.Reader, uint8, error)

Decode begins the decoding process; all versions are base64url-encoded bytes prefixed with a uint8 version number. Decode returns a reader of the bytes right after the version, and the version number.

func DecodeV1

func DecodeV1(r io.Reader) (*bufio.Scanner, error)

DecodeV1 returns a bufio.Scanner that returns each encoded path. The reader should already be read past the version number; Decode() above does exactly this.

func DecodeV1Path

func DecodeV1Path(path string) (*pfs.File, error)

DecodeV1Path decodes a V1 path. pachctl's convention of branch=commit is not supported.

func EncodeV1

func EncodeV1(paths []string) (string, error)

EncodeV1 generates a V1 archive URL string.

Types

type ArchiveFormat

type ArchiveFormat string

ArchiveFormat is the file format to produce.

const (
	ArchiveFormatZip ArchiveFormat = "zip" // A ZIP file.
)

func (ArchiveFormat) ContentType

func (f ArchiveFormat) ContentType() string

type ArchiveRequest

type ArchiveRequest struct {
	Format ArchiveFormat // The desired format of the archive.
	// contains filtered or unexported fields
}

An ArchiveRequest is a valid archive download URL.

func ArchiveFromURL

func ArchiveFromURL(u *url.URL) (*ArchiveRequest, error)

ArchiveFromURL parses a URL into an ArchiveRequest.

func (*ArchiveRequest) ForEachPath

func (req *ArchiveRequest) ForEachPath(cb func(path string) error) error

ForEachPath calls the callback with each requested file.

type HTTP

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

HTTP is an http.Server that serves the archiveserver endpoints.

func NewHTTP

func NewHTTP(port uint16, pachClientFactory func(ctx context.Context) *client.APIClient) *HTTP

NewHTTP creates a new Archive Server and an HTTP server to serve it on.

func (*HTTP) ListenAndServe

func (h *HTTP) ListenAndServe(ctx context.Context) error

ListenAndServe begins serving the server, and returns when the context is canceled or the server dies on its own.

type Server

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

Server is an http.Handler that can download archives of PFS files.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler for the /download/ route.

Jump to

Keyboard shortcuts

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