Home Download Docs Code Community
import "perkeep/pkg/server"
Overview
Index
Subdirectories

Overview ▾

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

Index

func ServeStaticFile(rw http.ResponseWriter, req *http.Request, root fs.FS, file string)
type DownloadHandler
    func (dh *DownloadHandler) ServeFile(w http.ResponseWriter, r *http.Request, file blob.Ref)
    func (dh *DownloadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type FileTreeHandler
    func (fth *FileTreeHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
type FileTreeNode
type FileTreeResponse
type HelpHandler
    func (hh *HelpHandler) InitHandler(hl blobserver.FindHandlerByTyper) error
    func (hh *HelpHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
    func (hh *HelpHandler) SetServerConfig(config jsonconfig.Obj)
type ImageHandler
    func (ih *ImageHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request, file blob.Ref)
type RootHandler
    func (rh *RootHandler) SearchHandler() (h *search.Handler, ok bool)
    func (rh *RootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type SetupHandler
    func (sh *SetupHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
type StatusHandler
    func (sh *StatusHandler) InitHandler(hl blobserver.FindHandlerByTyper) error
    func (sh *StatusHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
type SyncHandler
    func NewSyncHandler(srcName, destName string, src blobserver.Storage, dest blobReceiverEnumerator, pendingQueue sorted.KeyValue) *SyncHandler
    func (sh *SyncHandler) EnumerateBlobs(ctx context.Context, dest chan<- blob.SizedRef, after string, limit int) error
    func (sh *SyncHandler) Fetch(context.Context, blob.Ref) (file io.ReadCloser, size uint32, err error)
    func (sh *SyncHandler) IdleWait()
    func (sh *SyncHandler) InitHandler(hl blobserver.FindHandlerByTyper) error
    func (sh *SyncHandler) ReceiveBlob(ctx context.Context, br blob.Ref, r io.Reader) (sb blob.SizedRef, err error)
    func (sh *SyncHandler) RemoveBlobs(ctx context.Context, blobs []blob.Ref) error
    func (sh *SyncHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
    func (sh *SyncHandler) StatBlobs(ctx context.Context, blobs []blob.Ref, fn func(blob.SizedRef) error) error
    func (sh *SyncHandler) String() string
type ThumbMeta
    func NewThumbMeta(kv sorted.KeyValue) *ThumbMeta
    func (m *ThumbMeta) Get(key string) (blob.Ref, error)
    func (m *ThumbMeta) Put(key string, br blob.Ref) error
type UIHandler
    func (ui *UIHandler) InitHandler(hl blobserver.FindHandlerByTyper) error
    func (ui *UIHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Package files

cgo_probe.go doc.go download.go filetree.go help.go image.go import_share.go root.go root_normal.go share.go status.go sync.go thumbcache.go ui.go uploadhelper.go wizard.go

func ServeStaticFile

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

ServeStaticFile serves file from the root virtual filesystem.

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>[?inline=1]

Serves the file described by the requested file schema blobref. if inline=1 the Content-Disposition of the response is set to inline, and otherwise it set to attachment.

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 schema.CamliType `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(context.Context, 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(ctx context.Context, br blob.Ref, r io.Reader) (sb blob.SizedRef, err error)

func (*SyncHandler) RemoveBlobs

func (sh *SyncHandler) RemoveBlobs(ctx context.Context, blobs []blob.Ref) error

func (*SyncHandler) ServeHTTP

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

func (*SyncHandler) StatBlobs

func (sh *SyncHandler) StatBlobs(ctx context.Context, blobs []blob.Ref, fn func(blob.SizedRef) error) 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)

Subdirectories

Name      Synopsis
..
app      Package app helps with configuring and starting server applications from Perkeep.
Website layout inspired by memcached.
Content by the authors.