rest-server: Index | Files

package restserver

import ""


Package Files

handlers.go htpasswd.go maxsizewriter.go metrics.go mux.go


const CheckInterval = 30 * time.Second

CheckInterval represents how often we check for changes in htpasswd file.

func NewHandler Uses

func NewHandler(server Server) *goji.Mux

NewHandler returns the master HTTP multiplexer/router.

type Blob Uses

type Blob struct {
    Name string `json:"name"`
    Size int64  `json:"size"`

Blob represents a single blob, its name and its size.

type HtpasswdFile Uses

type HtpasswdFile struct {
    Users map[string]string
    // contains filtered or unexported fields

HtpasswdFile is a map for usernames to passwords.

func NewHtpasswdFromFile Uses

func NewHtpasswdFromFile(path string) (*HtpasswdFile, error)

NewHtpasswdFromFile reads the users and passwords from a htpasswd file and returns them. If an error is encountered, it is returned, together with a nil-Pointer for the HtpasswdFile.

func (*HtpasswdFile) Reload Uses

func (h *HtpasswdFile) Reload() error

Reload reloads the htpasswd file. If the reload fails, the Users map is not changed and the error is returned.

func (*HtpasswdFile) ReloadCheck Uses

func (h *HtpasswdFile) ReloadCheck() error

ReloadCheck checks at most once per CheckInterval if the file changed and will reload the file if it did. It logs errors and successful reloads, and returns an error if any was encountered.

func (*HtpasswdFile) Validate Uses

func (h *HtpasswdFile) Validate(user string, password string) bool

Validate returns true if password matches the stored password for user. If no password for user is stored, or the password is wrong, false is returned.

type Server Uses

type Server struct {
    Path         string
    Listen       string
    Log          string
    CPUProfile   string
    TLSKey       string
    TLSCert      string
    TLS          bool
    NoAuth       bool
    AppendOnly   bool
    PrivateRepos bool
    Prometheus   bool
    Debug        bool
    MaxRepoSize  int64
    // contains filtered or unexported fields

Server determines how a Mux's handlers behave.

func (*Server) AuthHandler Uses

func (s *Server) AuthHandler(f *HtpasswdFile, h http.Handler) http.HandlerFunc

AuthHandler wraps h with a http.HandlerFunc that performs basic authentication against the user/passwords pairs stored in f and returns the http.HandlerFunc.

func (*Server) CheckBlob Uses

func (s *Server) CheckBlob(w http.ResponseWriter, r *http.Request)

CheckBlob tests whether a blob exists.

func (*Server) CheckConfig Uses

func (s *Server) CheckConfig(w http.ResponseWriter, r *http.Request)

CheckConfig checks whether a configuration exists.

func (*Server) CreateRepo Uses

func (s *Server) CreateRepo(w http.ResponseWriter, r *http.Request)

CreateRepo creates repository directories.

func (*Server) DeleteBlob Uses

func (s *Server) DeleteBlob(w http.ResponseWriter, r *http.Request)

DeleteBlob deletes a blob from the repository.

func (*Server) DeleteConfig Uses

func (s *Server) DeleteConfig(w http.ResponseWriter, r *http.Request)

DeleteConfig removes a config.

func (*Server) GetBlob Uses

func (s *Server) GetBlob(w http.ResponseWriter, r *http.Request)

GetBlob retrieves a blob from the repository.

func (*Server) GetConfig Uses

func (s *Server) GetConfig(w http.ResponseWriter, r *http.Request)

GetConfig allows for a config to be retrieved.

func (*Server) ListBlobs Uses

func (s *Server) ListBlobs(w http.ResponseWriter, r *http.Request)

ListBlobs lists all blobs of a given type in an arbitrary order.

func (*Server) ListBlobsV1 Uses

func (s *Server) ListBlobsV1(w http.ResponseWriter, r *http.Request)

ListBlobsV1 lists all blobs of a given type in an arbitrary order.

func (*Server) ListBlobsV2 Uses

func (s *Server) ListBlobsV2(w http.ResponseWriter, r *http.Request)

ListBlobsV2 lists all blobs of a given type, together with their sizes, in an arbitrary order.

func (*Server) SaveBlob Uses

func (s *Server) SaveBlob(w http.ResponseWriter, r *http.Request)

SaveBlob saves a blob to the repository.

func (*Server) SaveConfig Uses

func (s *Server) SaveConfig(w http.ResponseWriter, r *http.Request)

SaveConfig allows for a config to be saved.

Package restserver imports 27 packages (graph) and is imported by 2 packages. Updated 2018-06-21. Refresh now. Tools for package owners.