docsrv

package
v0.0.0-...-91901bc Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2017 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config map[string]ProjectConfig

Config is a map from hosts to project configurations.

func LoadConfig

func LoadConfig(file string) (Config, error)

LoadConfig loads the config from the given file.

func (Config) MinVersionForHost

func (c Config) MinVersionForHost(host string) *semver.Version

MinVersionForHost will return the minimum version for a project at the given host. It will return nil if no such host can be found or if the version is not valid or is missing. The host will have its port, if any, stripped.

func (Config) ProjectForHost

func (c Config) ProjectForHost(host string) (owner, repo string, ok bool)

ProjectForHost will returns the owner and repository name of the project in the given host. Will also report whether or not the project could be found with a boolean. The host will have its port, if any, stripped.

type Options

type Options struct {
	// GitHubAPIKey is the API key used to retrieve releases from GitHub.
	// If api key is empty the requests will be made without authentication.
	GitHubAPIKey string
	// BaseFolder is the path to the root folder of the webserver.
	BaseFolder string
	// SharedFolder is the path to the folder used to store all the common
	// assets for building the documentations.
	SharedFolder string
	// RefreshToken is a key that allows refreshing the cache before a regular
	// refresh on a request.
	RefreshToken string
	// Config is a mapping between hosts and project configurations.
	Config Config
}

Options contains all the options available for creating a new DocSrv service.

type ProjectConfig

type ProjectConfig struct {
	// Repository is the repository this project maps to in the format "${OWNER}/${PROJECT}".
	Repository string `toml:"repository"`
	// MinVersion is the minimum version of this project for which documentation
	// sites can be built.
	MinVersion string `toml:"min-version"`
}

ProjectConfig represents a single project configuration.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the main docsrv service.

func New

func New(opts Options) *Service

New creates a new DocSrv service with the given options.

func (*Service) ManageIndex

func (s *Service) ManageIndex(refreshInterval time.Duration, ctx context.Context)

ManageIndex is in charge of refreshing the index of projects every five minutes until the given context is cancelled.

func (*Service) ServeHTTP

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

Jump to

Keyboard shortcuts

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