go.bigb.es/curator

v1.0.0
Doc Versions Source

Functions

f func ModuleName

src
func ModuleName(path string) string

ModuleName extracts the top-level module name from a URL path.

f func ParseAdminToken

src
func ParseAdminToken(value string) (string, error)

ParseAdminToken resolves an admin token value. If value starts with "@", the rest is treated as a file path and the token is read from the first non-empty, non-comment line.

f func ParseAuthTokens

src
func ParseAuthTokens(value string) (map[string]struct{}, error)

ParseAuthTokens parses auth tokens from a value. If value starts with "@", the rest is treated as a file path (one token per line, # comments supported). Otherwise the value is split on commas.

f func ParseDocPath

src
func ParseDocPath(urlPath string) (modName, version, subpath string)

ParseDocPath parses documentation URLs: "/<module>@<version>/<subpath>". Returns the module name, version (empty if not specified), and sub-path.

f func ParseLatestPath

src
func ParseLatestPath(urlPath string) (escapedModPath string, ok bool)

ParseLatestPath parses "/<module>/@latest" paths. Returns the escaped module path if the URL matches, or empty string if not.

f func ParseProxyPath

src
func ParseProxyPath(urlPath string) (modPath, file string, ok bool)

ParseProxyPath parses "/<module>/@v/<file>" paths. Returns the full module path and file component (e.g. "list", "v1.0.0.info").

f func StorageKey

src
func StorageKey(modName, file string) string

StorageKey returns the S3 key for a proxy artifact.

Types

T type Server

src
type Server struct {
	Cfg         *config.Config
	Resolver    store.ModuleResolver
	Git         *git.Cache
	Store       storage.Storage
	AuthTokens  map[string]struct{}
	HTTPClient  *http.Client
	DocRenderer *dochtml.Renderer
}

m func (*Server) CanAccessModule

src
func (s *Server) CanAccessModule(modName string, r *http.Request) bool

CanAccessModule returns true if the request is allowed to access the module.

m func (*Server) ServeHTTP

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

m func (*Server) SumdbAuthMiddleware

src
func (s *Server) SumdbAuthMiddleware(next http.Handler) http.Handler

SumdbAuthMiddleware wraps the sumdb handler to enforce access control on lookups.

m func (*Server) SumdbHandler

src
func (s *Server) SumdbHandler(local http.Handler, upstream, prefix string) http.Handler

SumdbHandler returns a handler that serves local sumdb for our modules and proxies to upstream sumdb for everything else.