Documentation ¶
Index ¶
- func AuthMiddleware(s *State) func(http.Handler) http.Handler
- func SecureMiddleware(s *State) func(http.Handler) http.Handler
- type AllDirsHandler
- type AllDirsResponse
- type Commit
- type CopyHandler
- type CopyRequest
- type DeletedPathsHandler
- type DeletedPathsResponse
- type DeletedRequest
- type Diff
- type DiffPair
- type EventsHandler
- type GetHandler
- type HistoryEntry
- type HistoryHandler
- type HistoryRequest
- type HistoryResponse
- type IndexHandler
- type LogHandler
- type LogRequest
- type LogResponse
- type LoginHandler
- type LoginRequest
- type LoginResponse
- type LogoutHandler
- type LsHandler
- type LsRequest
- type LsResponse
- type MkdirHandler
- type MkdirRequest
- type MoveHandler
- type MoveRequest
- type PinHandler
- type PinRequest
- type PingHandler
- type PingResponse
- type RedirHandler
- type RemoteAddRequest
- type RemoteDiffRequest
- type RemoteDiffResponse
- type RemoteListHandler
- type RemoteListResponse
- type RemoteRemoveRequest
- type RemoteSelfHandler
- type RemoteSelfResponse
- type RemoteSyncRequest
- type RemotesAddHandler
- type RemotesDiffHandler
- type RemotesModifyHandler
- type RemotesRemoveHandler
- type RemotesSyncHandler
- type RemoveHandler
- type RemoveRequest
- type ResetHandler
- type ResetRequest
- type StatInfo
- type State
- type UndeleteHandler
- type UndeleteRequest
- type UploadHandler
- type WhoamiHandler
- type WhoamiResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
AuthMiddleware returns a new handler wrapper, that will require all calls to the respective handler to have a "sess" cookie with a valid user name.
Types ¶
type AllDirsHandler ¶
type AllDirsHandler struct {
*State
}
AllDirsHandler implements http.Handler. This endpoint returns all directories that the client may see. It is used in the client to offer the user a list of directories to move or copy files to.
func NewAllDirsHandler ¶
func NewAllDirsHandler(s *State) *AllDirsHandler
NewAllDirsHandler returns a new AllDirsHandler.
func (*AllDirsHandler) ServeHTTP ¶
func (ah *AllDirsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type AllDirsResponse ¶
AllDirsResponse is the response sent to the client.
type Commit ¶
type Commit struct { Date int64 `json:"date"` Msg string `json:"msg"` Tags []string `json:"tags"` Hash string `json:"hash"` Index int64 `json:"index"` }
Commit is the same as catfs.Commit, but JSON friendly and with some omitted fields that are not used by the client.
type CopyHandler ¶
type CopyHandler struct {
*State
}
CopyHandler implements http.Handler.
func NewCopyHandler ¶
func NewCopyHandler(s *State) *CopyHandler
NewCopyHandler creates a new copy handler.
func (*CopyHandler) ServeHTTP ¶
func (ch *CopyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type CopyRequest ¶
type CopyRequest struct { // Source is the path to the old node. Source string `json="source"` // Destination is the path of the new node. Destination string `json="destination"` }
CopyRequest is the request that can be send to this endpoint.
type DeletedPathsHandler ¶
type DeletedPathsHandler struct {
*State
}
DeletedPathsHandler implements http.Handler. This endpoint returns all directories that the client may see. It is used in the client to offer the user a list of directories to move or copy files to.
func NewDeletedPathsHandler ¶
func NewDeletedPathsHandler(s *State) *DeletedPathsHandler
NewDeletedPathsHandler returns a new DeletedPathsHandler.
func (*DeletedPathsHandler) ServeHTTP ¶
func (dh *DeletedPathsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type DeletedPathsResponse ¶
type DeletedPathsResponse struct { Success bool `json:"success"` Entries []*StatInfo `json:"entries"` }
DeletedPathsResponse is the response sent to the client.
type DeletedRequest ¶
type DeletedRequest struct { Offset int64 `json:"offset"` Limit int64 `json:"limit"` Filter string `json:"filter"` }
DeletedRequest is the data sent to this endpoint.
type Diff ¶
type Diff struct { Added []*StatInfo `json:"added"` Removed []*StatInfo `json:"removed"` Ignored []*StatInfo `json:"ignored"` Missing []*StatInfo `json:"missing"` Conflict []DiffPair `json:"conflict"` Moved []DiffPair `json:"moved"` Merged []DiffPair `json:"merged"` }
Diff is like catfs.Diff, but json-ized.
type DiffPair ¶
DiffPair is like catfs.DiffPair, but with some fields removed and with json instructions.
type EventsHandler ¶
type EventsHandler struct {
// contains filtered or unexported fields
}
EventsHandler implements http.Handler
func NewEventsHandler ¶
func NewEventsHandler(rapi remotesapi.RemotesAPI, ev *events.Listener) *EventsHandler
NewEventsHandler returns a new EventsHandler
func (*EventsHandler) Notify ¶
func (eh *EventsHandler) Notify(ctx context.Context, msg string) error
Notify sends `msg` to all connected clients, but stops in case `ctx` was canceled before sending it all.
func (*EventsHandler) ServeHTTP ¶
func (eh *EventsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*EventsHandler) Shutdown ¶
func (eh *EventsHandler) Shutdown()
Shutdown closes all open websockets.
type GetHandler ¶
type GetHandler struct {
*State
}
GetHandler implements http.Handler
func NewGetHandler ¶
func NewGetHandler(s *State) *GetHandler
NewGetHandler returns a new GetHandler
func (*GetHandler) ServeHTTP ¶
func (gh *GetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type HistoryEntry ¶
type HistoryEntry struct { Head Commit `json:"head"` Path string `json:"path"` Change string `json:"change"` IsPinned bool `json:"is_pinned"` IsExplicit bool `json:"is_explicit"` }
HistoryEntry is one entry in the response.
type HistoryHandler ¶
type HistoryHandler struct {
*State
}
HistoryHandler implements http.Handler
func NewHistoryHandler ¶
func NewHistoryHandler(s *State) *HistoryHandler
NewHistoryHandler returns a new HistoryHandler
func (*HistoryHandler) ServeHTTP ¶
func (hh *HistoryHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type HistoryRequest ¶
type HistoryRequest struct {
Path string `json:"path"`
}
HistoryRequest is the request sent to this endpoint.
type HistoryResponse ¶
type HistoryResponse struct { Success bool `json:"success"` Entries []HistoryEntry `json:"entries"` }
HistoryResponse is the data that is sent back to the client.
type IndexHandler ¶
type IndexHandler struct {
*State
}
IndexHandler implements http.Handler. It serves index.html from either file or memory.
func NewIndexHandler ¶
func NewIndexHandler(s *State) *IndexHandler
NewIndexHandler returns a new IndexHandler.
func (*IndexHandler) ServeHTTP ¶
func (ih *IndexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type LogHandler ¶
type LogHandler struct {
*State
}
LogHandler implements http.Handler.
func NewLogHandler ¶
func NewLogHandler(s *State) *LogHandler
NewLogHandler returns a new LogHandler
func (*LogHandler) ServeHTTP ¶
func (lh *LogHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type LogRequest ¶
type LogRequest struct { Offset int64 `json:"offset"` Limit int64 `json:"limit"` Filter string `json:"filter"` }
LogRequest is the data sent to this endpoint.
type LogResponse ¶
type LogResponse struct { Success bool `json:"success"` HaveStagedChanges bool `json:"have_staged_changes"` Commits []Commit `json:"commits"` }
LogResponse is the response sent back to the client.
type LoginHandler ¶
type LoginHandler struct {
*State
}
LoginHandler implements http.Handler
func NewLoginHandler ¶
func NewLoginHandler(s *State) *LoginHandler
NewLoginHandler creates a new LoginHandler
func (*LoginHandler) ServeHTTP ¶
func (lih *LoginHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type LoginRequest ¶
LoginRequest is the request sent as JSON to this endpoint.
type LoginResponse ¶
type LoginResponse struct { Success bool `json:"success"` Username string `json:"username"` Rights []string `json:"rights"` IsAnon bool `json:"is_anon"` AnonIsAllowed bool `json:"anon_is_allowed"` }
LoginResponse is what the endpoint will return.
type LogoutHandler ¶
type LogoutHandler struct {
*State
}
LogoutHandler implements http.Handler
func NewLogoutHandler ¶
func NewLogoutHandler(s *State) *LogoutHandler
NewLogoutHandler returns a new LogoutHandler
func (*LogoutHandler) ServeHTTP ¶
func (loh *LogoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type LsResponse ¶
type LsResponse struct { Success bool `json:"success"` Self *StatInfo `json:"self"` Files []*StatInfo `json:"files"` IsFiltered bool `json:"is_filtered"` }
LsResponse is the response sent back to the client.
type MkdirHandler ¶
type MkdirHandler struct {
*State
}
MkdirHandler implements http.Handler.
func NewMkdirHandler ¶
func NewMkdirHandler(s *State) *MkdirHandler
NewMkdirHandler creates a new mkdir handler.
func (*MkdirHandler) ServeHTTP ¶
func (mh *MkdirHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type MkdirRequest ¶
type MkdirRequest struct { // Path to create. Path string `json:"path"` }
MkdirRequest is the request that can be sent to this endpoint as JSON.
type MoveHandler ¶
type MoveHandler struct {
*State
}
MoveHandler implements http.Handler.
func NewMoveHandler ¶
func NewMoveHandler(s *State) *MoveHandler
NewMoveHandler creates a new move handler.
func (*MoveHandler) ServeHTTP ¶
func (mh *MoveHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type MoveRequest ¶
type MoveRequest struct { // Source is the path to the old node. Source string `json:"source"` // Destination is the path of the new node. Destination string `json:"destination"` }
MoveRequest is the request that can be send to this endpoint.
type PinHandler ¶
type PinHandler struct { *State // contains filtered or unexported fields }
PinHandler implements http.Handler.
func NewPinHandler ¶
func NewPinHandler(s *State) *PinHandler
NewPinHandler returns a new PinHandler
func NewUnpinHandler ¶
func NewUnpinHandler(s *State) *PinHandler
NewUnpinHandler returns a new PinHandler
func (*PinHandler) ServeHTTP ¶
func (ph *PinHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type PinRequest ¶
type PinRequest struct { Path string `json:"path"` Revision string `json:"revision"` DoPin bool `json:"do_pin"` }
PinRequest is the request that is being sent to the endpoint.
type PingHandler ¶
type PingHandler struct {
*State
}
PingHandler implements http.Handler. This handler checks if a user is already logged in.
func NewPingHandler ¶
func NewPingHandler(s *State) *PingHandler
NewPingHandler returns a new PingHandler.
func (*PingHandler) ServeHTTP ¶
func (wh *PingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type PingResponse ¶
type PingResponse struct {
IsOnline bool `json:"is_online"`
}
PingResponse is the response sent back by this endpoint.
type RedirHandler ¶
type RedirHandler struct {
// contains filtered or unexported fields
}
RedirHandler implements http.Handler. It redirects all of its requests to the respective https:// route.
func NewHTTPRedirectHandler ¶
func NewHTTPRedirectHandler(redirPort int64) *RedirHandler
NewHTTPRedirectHandler returns a new RedirHandler
func (*RedirHandler) ServeHTTP ¶
func (rh *RedirHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
type RemoteAddRequest ¶
type RemoteAddRequest struct { Name string `json:"name"` Folders []remotesapi.Folder `json:"folders"` Fingerprint string `json:"fingerprint"` AcceptAutoUpdates bool `json:"accept_auto_updates"` AcceptPush bool `json:"accept_push"` ConflictStrategy string `json:"conflict_strategy"` }
RemoteAddRequest is the data being sent to this endpoint.
type RemoteDiffRequest ¶
type RemoteDiffRequest struct {
Name string `json:"name"`
}
RemoteDiffRequest is the data being sent to this endpoint.
type RemoteDiffResponse ¶
RemoteDiffResponse is the data being sent to this endpoint.
type RemoteListHandler ¶
type RemoteListHandler struct {
*State
}
RemoteListHandler implements http.Handler
func NewRemotesListHandler ¶
func NewRemotesListHandler(s *State) *RemoteListHandler
NewRemotesListHandler returns a new RemoteListHandler
func (*RemoteListHandler) ServeHTTP ¶
func (rh *RemoteListHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RemoteListResponse ¶
type RemoteListResponse struct { Success bool `json:"success"` Remotes []*remotesapi.Remote `json:"remotes"` }
RemoteListResponse is the response given by this endpoint.
type RemoteRemoveRequest ¶
type RemoteRemoveRequest struct {
Name string `json:"name"`
}
RemoteRemoveRequest is the data being sent to this endpoint.
type RemoteSelfHandler ¶
type RemoteSelfHandler struct {
*State
}
RemoteSelfHandler implements http.Handler
func NewRemotesSelfHandler ¶
func NewRemotesSelfHandler(s *State) *RemoteSelfHandler
NewRemotesSelfHandler returns a new RemoteSelfHandler
func (*RemoteSelfHandler) ServeHTTP ¶
func (rh *RemoteSelfHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RemoteSelfResponse ¶
type RemoteSelfResponse struct { Success bool `json:"success"` Self remotesapi.Identity `json:"self"` DefaultConflictStrategy string `json:"default_conflict_strategy"` }
RemoteSelfResponse is the data being sent to this endpoint.
type RemoteSyncRequest ¶
type RemoteSyncRequest struct {
Name string `json:"name"`
}
RemoteSyncRequest is the data being sent to this endpoint.
type RemotesAddHandler ¶
type RemotesAddHandler struct {
*State
}
RemotesAddHandler implements http.Handler
func NewRemotesAddHandler ¶
func NewRemotesAddHandler(s *State) *RemotesAddHandler
NewRemotesAddHandler returns a new RemotesAddHandler
func (*RemotesAddHandler) ServeHTTP ¶
func (rh *RemotesAddHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RemotesDiffHandler ¶
type RemotesDiffHandler struct {
*State
}
RemotesDiffHandler implements http.Handler
func NewRemotesDiffHandler ¶
func NewRemotesDiffHandler(s *State) *RemotesDiffHandler
NewRemotesDiffHandler returns a new RemotesDiffHandler
func (*RemotesDiffHandler) ServeHTTP ¶
func (rh *RemotesDiffHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RemotesModifyHandler ¶
type RemotesModifyHandler struct {
*State
}
RemotesModifyHandler implements http.Handler
func NewRemotesModifyHandler ¶
func NewRemotesModifyHandler(s *State) *RemotesModifyHandler
NewRemotesModifyHandler returns a new RemotesModifyHandler
func (*RemotesModifyHandler) ServeHTTP ¶
func (rh *RemotesModifyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RemotesRemoveHandler ¶
type RemotesRemoveHandler struct {
*State
}
RemotesRemoveHandler implements http.Handler
func NewRemotesRemoveHandler ¶
func NewRemotesRemoveHandler(s *State) *RemotesRemoveHandler
NewRemotesRemoveHandler returns a new RemotesRemoveHandler
func (*RemotesRemoveHandler) ServeHTTP ¶
func (rh *RemotesRemoveHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RemotesSyncHandler ¶
type RemotesSyncHandler struct {
*State
}
RemotesSyncHandler implements http.Handler
func NewRemotesSyncHandler ¶
func NewRemotesSyncHandler(s *State) *RemotesSyncHandler
NewRemotesSyncHandler returns a new RemotesSyncHandler
func (*RemotesSyncHandler) ServeHTTP ¶
func (rh *RemotesSyncHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RemoveHandler ¶
type RemoveHandler struct {
*State
}
RemoveHandler implements http.Handler.
func NewRemoveHandler ¶
func NewRemoveHandler(s *State) *RemoveHandler
NewRemoveHandler returns a new RemoveHandler
func (*RemoveHandler) ServeHTTP ¶
func (rh *RemoveHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RemoveRequest ¶
type RemoveRequest struct {
Paths []string `json:"paths"`
}
RemoveRequest is the request that is being sent to the endpoint.
type ResetHandler ¶
type ResetHandler struct {
*State
}
ResetHandler implements http.Handler.
func NewResetHandler ¶
func NewResetHandler(s *State) *ResetHandler
NewResetHandler returns a new ResetHandler.
func (*ResetHandler) ServeHTTP ¶
func (rh *ResetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ResetRequest ¶
type ResetRequest struct { Path string `json:"path"` Revision string `json:"revision"` Force bool `json:"force"` }
ResetRequest is a request sent to this endpoint.
type StatInfo ¶
type StatInfo struct { Path string `json:"path"` User string `json:"user"` Size uint64 `json:"size"` Inode uint64 `json:"inode"` Depth int `json:"depth"` ModTime int64 `json:"last_modified_ms"` IsDir bool `json:"is_dir"` IsPinned bool `json:"is_pinned"` IsExplicit bool `json:"is_explicit"` }
StatInfo is a single node in the list response. It is the same as catfs.StatInfo, but is more JSON friendly and omits some fields like hashes that are not useful to the client.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is a helper struct that contains all API objects that might be useful to the endpoint implementation. It does not serve other purposes.
func NewState ¶
func NewState( fs *catfs.FS, rapi remotesapi.RemotesAPI, cfg *config.Config, evHdl *EventsHandler, ev *events.Listener, userDb *db.UserDatabase, ) (*State, error)
NewState creates a new state object. events.Listener can be set later with SetEventListener.
func (*State) UserDatabase ¶
func (s *State) UserDatabase() *db.UserDatabase
UserDatabase returns the currently opened user database.
type UndeleteHandler ¶
type UndeleteHandler struct {
*State
}
UndeleteHandler implements http.Handler.
func NewUndeleteHandler ¶
func NewUndeleteHandler(s *State) *UndeleteHandler
NewUndeleteHandler creates a new undelete handler.
func (*UndeleteHandler) ServeHTTP ¶
func (uh *UndeleteHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type UndeleteRequest ¶
type UndeleteRequest struct { // Path to create. Path string `json:"path"` }
UndeleteRequest is the request that can be sent to this endpoint as JSON.
type UploadHandler ¶
type UploadHandler struct {
*State
}
UploadHandler implements http.Handler.
func NewUploadHandler ¶
func NewUploadHandler(s *State) *UploadHandler
NewUploadHandler returns a new UploadHandler.
func (*UploadHandler) ServeHTTP ¶
func (uh *UploadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type WhoamiHandler ¶
type WhoamiHandler struct {
*State
}
WhoamiHandler implements http.Handler. This handler checks if a user is already logged in.
func NewWhoamiHandler ¶
func NewWhoamiHandler(s *State) *WhoamiHandler
NewWhoamiHandler returns a new WhoamiHandler.
func (*WhoamiHandler) ServeHTTP ¶
func (wh *WhoamiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)