Documentation ¶
Overview ¶
Package app glues your routes together to generate files concurrently or host them in a server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultLog ¶
func DefaultLog() logrus.FieldLogger
DefaultLog returns the default log used for the App
func SettingsFromFile ¶
func SettingsFromFile(path string, settings interface{}, log logrus.FieldLogger)
SettingsFromFile loads settings from the given file path into the given Settings
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is a wrapper around the router, to provide the functionality of the cli.App interface. Provides defaults to give the app structure and connects things together to generate route responses concurrently.
See cli.App interface for core functions.
func NewApp ¶
func NewApp(routeSetter Setter, settings *Settings, log logrus.FieldLogger) *App
NewApp returns a new instance of App
func (*App) FileServerPort ¶
FileServerPort returns the port of the file server
func (*App) Generate ¶
Generate generates the static web pages concurrently.
For speed and concurrency reasons (like file/map read/writing), this is done in two stages: First, the Tracker.IndependentURLs routes are generated. After, the Tracker.DependentURLs.
Use Tracker.AddDependentURL to generate the route's file during the second stage.
func (*App) GeneratedPath ¶
GeneratedPath returns the path of the generates files of the static web page
func (*App) Host ¶
Host runs a web application server that computes the route responses in real time
func (*App) RunFileServer ¶
RunFileServer runs the server to host the generated files of the static web page
func (*App) ServerPort ¶
ServerPort returns the port of the web application server
type GeneratorSettings ¶
type GeneratorSettings struct {
Concurrency int `json:"concurrency,omitempty"`
}
GeneratorSettings represents the settings for Generating files
type Setter ¶
type Setter interface { // SetRoutes is where you set the routes SetRoutes(r router.Router, tracker *Tracker) error // AssetsURL is the URL path prefix of all your assets, so the server can redirect this prefix to your assets AssetsURL() string // GeneratedAssetsPath is the local file path of the generated assets GeneratedAssetsPath() string }
Setter is an interface for App to talk to your code and set routes.
type Settings ¶
type Settings struct { GeneratedPath string `json:"generated_path,omitempty"` ServerPort int `json:"server_port,omitempty"` FileServerPort int `json:"file_server_port,omitempty"` GeneratorSettings *GeneratorSettings `json:"generator_settings,omitempty"` Content interface{} `json:"content,omitempty"` }
Settings represents the settings of App
func DefaultSettings ¶
func DefaultSettings() *Settings
DefaultSettings returns the default settings of the App
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker tracks all the routes/URLs of the static site, so that App knows to generate them
func NewTracker ¶
NewTracker returns a new instance of Tracker
func (*Tracker) AddDependentURL ¶
AddDependentURL adds a dependent url, so the url route runs in the second batch.
When generating the static website files (App.Generate), App works in 2 batches. First, the IndependentURLs() routes are run, then the DependentURLs() are run.
func (*Tracker) DependentURLs ¶
DependentURLs returns a slice of urls provided by AddDependentURL
func (*Tracker) IndependentURLs ¶
IndependentURLs = AllURLs - DependentURLs (see AddDependentURL)