rest

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2014 License: LGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QPath = "path"
	QType = "type"

	TypeAll  = "all"
	TypeSeal = "sealOnly"
)
View Source
const (
	ContentKey   = "Content-Type"
	JsonContent  = "application/json"
	PlainContent = "text/plain"
	HPIsRW       = "X-is-RW"
)

Variables

This section is empty.

Functions

func NewDirHandler

func NewDirHandler(stateProvider func() State) http.Handler

func NewStateHandler

func NewStateHandler(onStateChange func(bool, bool, api.Result, string), socketURL string) *restHandler

Returns a usable REST handler. The callback allows to respond to State-changes, calls to it are synchronized and thus serial only. f(isEnd, result) - isEnd is True only when the operation is now finished, result is nil in that case If isEnd is false and result is nil, this indicates that our State changed

Types

type ItemInfo

type ItemInfo struct {
	Item  string `json:"item"`
	Path  string `json:"path"`
	IsDir bool   `json:"isDir"`
}

Simple json compatible structure which identifies an item within a directory It also signals if it is a file

type State

type State struct {
	Mode         string   `json:"mode"`
	Verbosity    string   `json:"verbosity"`
	Spid         int      `json:"spid"`         // streams per input device
	Spod         int      `json:"spod"`         // streams per output device
	Fep          []string `json:"fep"`          // file exclude patterns
	Sources      []string `json:"sources"`      // The sources for verify and seal
	Destinations []string `json:"destinations"` // The destinations of sealed-copy
	Verify       string   `json:"verify"`       // if non-empty, verification is done after a sealed copy
	Format       string   `json:"format"`       // The serialization format of seals
	SocketURL    string   `json:"socketURL"`    // read-only URL of the web-socket people can connect to
	IsRunning    bool     `json:"status"`       // read-only, true if an operation is in progress

	LastError string `json:executionError` // error result of the last operation
}

A struct for json serialization and deserialization

func (*State) FromJson

func (s *State) FromJson(r io.Reader) error

instantiate ourselves from json. Automatically verifies ourselves to assure we are a valid State

func (*State) Json

func (s *State) Json(w io.Writer) error

Write ourselves to w as json

Jump to

Keyboard shortcuts

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