server

package
v0.0.0-...-3911a41 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2017 License: Apache-2.0 Imports: 68 Imported by: 0

Documentation

Overview

Package server implements the server HTTP interface for the UI, publishing, setup, status, sync, thubnailing, etc.

#fileembed pattern .+\.(ico)$

Index

Constants

This section is empty.

Variables

View Source
var Files = &fileembed.Files{}

Functions

func ServeStaticFile

func ServeStaticFile(rw http.ResponseWriter, req *http.Request, root http.FileSystem, file string)

ServeStaticFile serves file from the root virtual filesystem.

Types

type DownloadHandler

type DownloadHandler struct {
	Fetcher blob.Fetcher

	// Search is optional. If present, it's used to map a fileref
	// to a wholeref, if the Fetcher is of a type that knows how
	// to get at a wholeref more efficiently. (e.g. blobpacked)
	Search *search.Handler

	ForceMIME string // optional
	// contains filtered or unexported fields
}

func (*DownloadHandler) ServeFile

func (dh *DownloadHandler) ServeFile(w http.ResponseWriter, r *http.Request, file blob.Ref)

func (*DownloadHandler) ServeHTTP

func (dh *DownloadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP answers the following queries:

POST:

?files=sha1-foo,sha1-bar,sha1-baz

Creates a zip archive of the provided files and serves it in the response.

GET:

/<file-schema-blobref>

Serves the file described by the requested file schema blobref.

type FileTreeHandler

type FileTreeHandler struct {
	Fetcher blob.Fetcher
	// contains filtered or unexported fields
}

func (*FileTreeHandler) ServeHTTP

func (fth *FileTreeHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type FileTreeNode

type FileTreeNode struct {
	// Name is the basename of the node.
	Name string `json:"name"`
	// Type is the camliType of the node. This may be "file", "directory", "symlink"
	// or other in the future.
	Type string `json:"type"`
	// BlobRef is the blob.Ref of the node.
	BlobRef blob.Ref `json:"blobRef"`
}

FileTreeNode represents a file in a file tree. It is part of the FileTreeResponse.

type FileTreeResponse

type FileTreeResponse struct {
	// Children is the list of children files of a directory.
	Children []FileTreeNode `json:"children"`
}

FileTreeResponse is the JSON response for the FileTreeHandler.

type HelpHandler

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

HelpHandler publishes information related to accessing the server

func (*HelpHandler) InitHandler

func (hh *HelpHandler) InitHandler(hl blobserver.FindHandlerByTyper) error

func (*HelpHandler) ServeHTTP

func (hh *HelpHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*HelpHandler) SetServerConfig

func (hh *HelpHandler) SetServerConfig(config jsonconfig.Obj)

SetServerConfig enables the handler to receive the server config before InitHandler, which generates a client config from the server config, is called.

type ImageHandler

type ImageHandler struct {
	Fetcher             blob.Fetcher
	Search              *search.Handler    // optional
	Cache               blobserver.Storage // optional
	MaxWidth, MaxHeight int
	Square              bool
	ThumbMeta           *ThumbMeta    // optional cache index for scaled images
	ResizeSem           *syncutil.Sem // Limit peak RAM used by concurrent image thumbnail calls.
}

func (*ImageHandler) ServeHTTP

func (ih *ImageHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request, file blob.Ref)

type RootHandler

type RootHandler struct {
	// Stealth determines whether we hide from non-authenticated
	// clients.
	Stealth bool

	OwnerName string // for display purposes only.
	Username  string // default user for mobile setup.

	// URL prefixes (path or full URL) to the primary blob and
	// search root.
	BlobRoot   string
	SearchRoot string

	Prefix string // root handler's prefix

	// JSONSignRoot is the optional path or full URL to the JSON
	// Signing helper.
	JSONSignRoot string

	Storage blobserver.Storage // of BlobRoot, or nil
	// contains filtered or unexported fields
}

RootHandler handles serving the about/splash page.

func (*RootHandler) SearchHandler

func (rh *RootHandler) SearchHandler() (h *search.Handler, ok bool)

func (*RootHandler) ServeHTTP

func (rh *RootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SetupHandler

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

SetupHandler handles serving the wizard setup page.

func (*SetupHandler) ServeHTTP

func (sh *SetupHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type StatusHandler

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

StatusHandler publishes server status information.

func (*StatusHandler) InitHandler

func (sh *StatusHandler) InitHandler(hl blobserver.FindHandlerByTyper) error

func (*StatusHandler) ServeHTTP

func (sh *StatusHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type SyncHandler

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

The SyncHandler handles async replication in one direction between a pair storage targets, a source and target.

SyncHandler is a BlobReceiver but doesn't actually store incoming blobs; instead, it records blobs it has received and queues them for async replication soon, or whenever it can.

func NewSyncHandler

func NewSyncHandler(srcName, destName string,
	src blobserver.Storage, dest blobReceiverEnumerator,
	pendingQueue sorted.KeyValue) *SyncHandler

NewSyncHandler returns a handler that will asynchronously and continuously copy blobs from src to dest, if missing on dest. Blobs waiting to be copied are stored on pendingQueue. srcName and destName are only used for status and debugging messages. N.B: blobs should be added to src with a method that notifies the blob hub, such as blobserver.Receive.

func (*SyncHandler) EnumerateBlobs

func (sh *SyncHandler) EnumerateBlobs(ctx context.Context, dest chan<- blob.SizedRef, after string, limit int) error

func (*SyncHandler) Fetch

func (sh *SyncHandler) Fetch(blob.Ref) (file io.ReadCloser, size uint32, err error)

func (*SyncHandler) IdleWait

func (sh *SyncHandler) IdleWait()

IdleWait waits until the sync handler has finished processing the currently queued blobs.

func (*SyncHandler) InitHandler

func (sh *SyncHandler) InitHandler(hl blobserver.FindHandlerByTyper) error

func (*SyncHandler) ReceiveBlob

func (sh *SyncHandler) ReceiveBlob(br blob.Ref, r io.Reader) (sb blob.SizedRef, err error)

func (*SyncHandler) RemoveBlobs

func (sh *SyncHandler) RemoveBlobs(blobs []blob.Ref) error

func (*SyncHandler) ServeHTTP

func (sh *SyncHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*SyncHandler) StatBlobs

func (sh *SyncHandler) StatBlobs(dest chan<- blob.SizedRef, blobs []blob.Ref) error

func (*SyncHandler) String

func (sh *SyncHandler) String() string

type ThumbMeta

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

ThumbMeta is a mapping from an image's scaling parameters (encoding as an opaque "key" string) and the blobref of the thumbnail (currently its file schema blob). ThumbMeta is safe for concurrent use by multiple goroutines.

The key will be some string containing the original full-sized image's blobref, its target dimensions, and any possible transformations on it (e.g. cropping it to square).

func NewThumbMeta

func NewThumbMeta(kv sorted.KeyValue) *ThumbMeta

NewThumbMeta returns a new in-memory ThumbMeta, backed with the optional kv. If kv is nil, key/value pairs are stored in memory only.

func (*ThumbMeta) Get

func (m *ThumbMeta) Get(key string) (blob.Ref, error)

func (*ThumbMeta) Put

func (m *ThumbMeta) Put(key string, br blob.Ref) error

type UIHandler

type UIHandler struct {

	// Cache optionally specifies a cache blob server, used for
	// caching image thumbnails and other emphemeral data.
	Cache blobserver.Storage // or nil
	// contains filtered or unexported fields
}

UIHandler handles serving the UI and discovery JSON.

func (*UIHandler) InitHandler

func (ui *UIHandler) InitHandler(hl blobserver.FindHandlerByTyper) error

InitHandler goes through all the other configured handlers to discover the publisher ones, and uses them to populate ui.publishRoots.

func (*UIHandler) ServeHTTP

func (ui *UIHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Directories

Path Synopsis
Package app helps with configuring and starting server applications from Camlistore.
Package app helps with configuring and starting server applications from Camlistore.

Jump to

Keyboard shortcuts

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