Documentation ¶
Index ¶
- Constants
- Variables
- func NewGzipHandler(fn http.HandlerFunc) http.HandlerFunc
- type Context
- func (c *Context) IsChecksum() bool
- func (c *Context) IsFileStats() bool
- func (c *Context) IsMirrorStats() bool
- func (c *Context) IsMirrorlist() bool
- func (c *Context) IsPretty() bool
- func (c *Context) QueryParam(key string) string
- func (c *Context) Request() *http.Request
- func (c *Context) ResponseWriter() http.ResponseWriter
- func (c *Context) SecureOption() SecureOption
- func (c *Context) Templates() Templates
- func (c *Context) Type() RequestType
- type DefaultEngine
- type HTTP
- type JSONRenderer
- type MirrorListRenderer
- type MirrorStats
- type MirrorStatsPage
- type RedirectRenderer
- type RequestType
- type SecureOption
- type Stats
- type StatsFileNow
- type StatsFilePeriod
- type SyncOffset
- type Templates
Constants ¶
const ( STANDARD RequestType = iota MIRRORLIST FILESTATS MIRRORSTATS CHECKSUM UNDEFINED SecureOption = iota WITHTLS WITHOUTTLS )
Variables ¶
var ( // ErrTemplatesNotFound is returned cannot be loaded ErrTemplatesNotFound = errors.New("please set a valid path to the templates directory") )
Functions ¶
func NewGzipHandler ¶
func NewGzipHandler(fn http.HandlerFunc) http.HandlerFunc
NewGzipHandler is an HTTP handler used to compress responses if supported by the client
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context represents the context of a request
func NewContext ¶
NewContext returns a new instance of Context
func (*Context) IsChecksum ¶
IsChecksum returns true if a checksum has been requested
func (*Context) IsFileStats ¶
IsFileStats returns true if the file stats has been requested
func (*Context) IsMirrorStats ¶
IsMirrorStats returns true if the mirror stats has been requested
func (*Context) IsMirrorlist ¶
IsMirrorlist returns true if the mirror list has been requested
func (*Context) QueryParam ¶
QueryParam returns the value associated with the given query parameter
func (*Context) ResponseWriter ¶
func (c *Context) ResponseWriter() http.ResponseWriter
ResponseWriter returns the underlying http.ResponseWriter of the current request
func (*Context) SecureOption ¶
func (c *Context) SecureOption() SecureOption
SecureOption returns the selected secure option
func (*Context) Type ¶
func (c *Context) Type() RequestType
Type returns the type of the current request
type DefaultEngine ¶
type DefaultEngine struct{}
DefaultEngine is the default algorithm used for mirror selection
func (DefaultEngine) Selection ¶
func (h DefaultEngine) Selection(ctx *Context, cache *mirrors.Cache, fileInfo *filesystem.FileInfo, clientInfo network.GeoIPRecord) (mlist mirrors.Mirrors, excluded mirrors.Mirrors, err error)
Selection returns an ordered list of selected mirror, a list of rejected mirrors and and an error code
type HTTP ¶
type HTTP struct { Listener *net.Listener Restarting bool // contains filtered or unexported fields }
HTTP represents an instance of the HTTP webserver
func HTTPServer ¶
HTTPServer is the constructor of the HTTP server
func (*HTTP) LoadTemplates ¶
LoadTemplates pre-loads templates from the configured template directory
func (*HTTP) SetListener ¶
SetListener can be used to set a different listener that should be used by the HTTP server. This is primarily used during seamless binary upgrade.
func (*HTTP) Stop ¶
Stop gracefully stops the HTTP server with a timeout to let the remaining connections finish
type JSONRenderer ¶
type JSONRenderer struct{}
JSONRenderer is used to render JSON formatted details about the current request
type MirrorListRenderer ¶
type MirrorListRenderer struct{}
MirrorListRenderer is used to render the mirrorlist page using the HTML templates
func (*MirrorListRenderer) Type ¶
func (w *MirrorListRenderer) Type() string
Type returns the type of renderer
type MirrorStats ¶
type MirrorStats struct { ID int Name string Downloads int64 Bytes int64 PercentD float32 PercentB float32 SyncOffset SyncOffset }
MirrorStats contains the stats of a given mirror
type MirrorStatsPage ¶
type MirrorStatsPage struct { List []MirrorStats MirrorList []mirrors.Mirror LocalJSPath string }
MirrorStatsPage contains the values needed to generate the mirrorstats page
type RedirectRenderer ¶
type RedirectRenderer struct{}
RedirectRenderer is a basic renderer that redirects the user to the first mirror in the list
func (*RedirectRenderer) Type ¶
func (w *RedirectRenderer) Type() string
Type returns the type of renderer
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Stats is the internal structure for the download stats
func (*Stats) CountDownload ¶
CountDownload is a lightweight method used to count a new download for a specific file and mirror
type StatsFileNow ¶
StatsFileNow is the structure containing the latest stats of a file
type StatsFilePeriod ¶
StatsFilePeriod is the structure containing the stats for the given period
type SyncOffset ¶
SyncOffset contains the time offset between the mirror and the local repository