go.bigb.es/curator
Index
- func ModuleName(path string) string
- func ParseAdminToken(value string) (string, error)
- func ParseAuthTokens(value string) (map[string]struct{}, error)
- func ParseDocPath(urlPath string) (modName, version, subpath string)
- func ParseLatestPath(urlPath string) (escapedModPath string, ok bool)
- func ParseProxyPath(urlPath string) (modPath, file string, ok bool)
- func StorageKey(modName, file string) string
- type Server
Functions
func ModuleName(path string) string
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.
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.
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.
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.
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").
func StorageKey(modName, file string) string
StorageKey returns the S3 key for a proxy artifact.
Types
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 }
func (s *Server) CanAccessModule(modName string, r *http.Request) bool
CanAccessModule returns true if the request is allowed to access the module.
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (s *Server) SumdbAuthMiddleware(next http.Handler) http.Handler
SumdbAuthMiddleware wraps the sumdb handler to enforce access control on lookups.
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.
ModuleName extracts the top-level module name from a URL path.