go.bigb.es/curator

v1.4.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. Strips any @version suffix (e.g., "/curator@v1.0.0/..." → "curator"). For multi-segment paths, returns the first segment only. Use ResolveModulePath for paths that may contain multi-segment module names.

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. For multi-segment module paths, use ResolveModulePath instead.

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 ResolveModulePath

src
func ResolveModulePath(urlPath string, resolver func(name string) bool) (modName, version, subpath string)

ResolveModulePath finds the longest path prefix that matches a known module. Returns the module name and the remaining subpath. The resolver function returns true if the name is a known module. Handles @version in the path (e.g., "/projects/revizor@v1.0.0/sub/pkg").

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
	Credentials  store.CredentialResolver
	ModuleLister store.ModuleLister
	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) ServeLogout

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

ServeLogout handles POST /-/logout.

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.