pkg

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddContext added in v0.0.2

func AddContext(next http.Handler, option *ServerOptions) http.Handler

AddContext add context inject all handlers

func Execute

func Execute()

Execute will execute the command

func GetJSONServers added in v0.0.2

func GetJSONServers() map[string]string

GetJSONServers get all JSON servers

func GetProviders added in v0.0.2

func GetProviders() (providers []string)

GetProviders get all providers

func GetRootCmd added in v0.0.2

func GetRootCmd() *cobra.Command

GetRootCmd returns the root command

func HandleDefaultProvider added in v0.0.2

func HandleDefaultProvider(w http.ResponseWriter, r *http.Request)

HandleDefaultProvider handle /providers/default

func HandleJSONServers added in v0.0.2

func HandleJSONServers(w http.ResponseWriter, r *http.Request)

HandleJSONServers handle /json-servers

func HandleProviders added in v0.0.2

func HandleProviders(w http.ResponseWriter, r *http.Request)

HandleProviders handle /providers

func HandleUpdateCenter added in v0.0.2

func HandleUpdateCenter(w http.ResponseWriter, r *http.Request)

HandleUpdateCenter handle GET /update-center.json

Types

type CacheServer

type CacheServer interface {
	Load(string) string
	Save(string, string) error
}

CacheServer is the interface for saving a cache item

type FileSystemCacheServer

type FileSystemCacheServer struct {
	FileName string
	// contains filtered or unexported fields
}

FileSystemCacheServer save the cache into a filesystem

func (*FileSystemCacheServer) Load

func (c *FileSystemCacheServer) Load(key string) (val string)

Load load the key from a file

func (*FileSystemCacheServer) Save

func (c *FileSystemCacheServer) Save(key string, val string) (err error)

Save save the key into a file

type QuerySource added in v0.0.2

type QuerySource interface {
	Get(key string) string
}

QuerySource which contains the methods to query

type ServerOptions

type ServerOptions struct {
	Config string

	DefaultProvider   string
	DefaultJSONServer string

	Host    string
	Port    int
	PortLTS int

	CertFile string
	KeyFile  string

	Printer helper.Printer
}

ServerOptions represents the options for a server

func (*ServerOptions) GetAndCacheURL

func (o *ServerOptions) GetAndCacheURL(query UpdateCenterQuery) (targetURL *url.URL, err error)

GetAndCacheURL get the real URL, then cache it

func (*ServerOptions) GetProviderURL added in v0.0.2

func (o *ServerOptions) GetProviderURL(official *url.URL, query UpdateCenterQuery) (targetURL string)

GetProviderURL get the update center URL from a provider

func (*ServerOptions) GetURL

func (o *ServerOptions) GetURL(version string) (targetURL *url.URL, err error)

GetURL get the real URL from the official site

func (*ServerOptions) Run

func (o *ServerOptions) Run(cmd *cobra.Command, args []string) (err error)

Run startup a server

type UpdateCenterQuery added in v0.0.2

type UpdateCenterQuery struct {
	Version      string
	Provider     string
	JSONServer   string
	Experimental bool
}

UpdateCenterQuery holds the info for query a update center

func GetUpdateCenterQuery added in v0.0.2

func GetUpdateCenterQuery(querySources ...QuerySource) (query UpdateCenterQuery)

GetUpdateCenterQuery returns the query object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL