server

package
v0.0.0-...-04928c2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2015 License: Apache-2.0 Imports: 62 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
	Cache   blobserver.Storage

	// 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
}

func (*DownloadHandler) ServeHTTP

func (dh *DownloadHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request, file blob.Ref)

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 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

	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(rw http.ResponseWriter, req *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 (*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) 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 {
	// JSONSignRoot is the optional path or full URL to the JSON
	// Signing helper. Only used by the UI and thus necessary if
	// UI is true.
	// TODO(bradfitz): also move this up to the root handler,
	// if we start having clients (like phones) that we want to upload
	// but don't trust to have private signing keys?
	JSONSignRoot string

	// 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