Documentation ¶
Overview ¶
Package spa implements a single-page application used on the dmitri.shuralyov.com website.
It is capable of serving page HTML on the frontend and backend, and setting page state on the frontend.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewApp ¶
func NewApp( codeService interface { // ListDirectories lists directories in sorted order. ListDirectories(ctx context.Context) ([]*code.Directory, error) // GetDirectory looks up a directory by specified import path. // If the directory doesn't exist, os.ErrNotExist is returned. GetDirectory(ctx context.Context, importPath string) (*code.Directory, error) }, issueService issues.Service, changeService change.Service, notifService notification.Service, userService users.Service, redirect func(*url.URL), ) *app
Types ¶
type App ¶
type App interface { // ServePage renders the page HTML for reqURL to w, // and returns the state it computed. // // It returns an error of OutOfScopeError type // if reqURL is out of scope for the app. // // The returned state must implement the PageState interface. ServePage(ctx context.Context, w io.Writer, reqURL *url.URL) (interface{}, error) // SetupPage sets up the frontend page state, // using state returned from ServePage. SetupPage(ctx context.Context, state interface{}) }
An App is a single-page application.
type OutOfScopeError ¶
OutOfScopeError is an error returned when the requested page is out of scope for the single-page application and therefore cannot be served by it directly.
func IsOutOfScope ¶
func IsOutOfScope(err error) (OutOfScopeError, bool)
IsOutOfScope reports whether err is an OutOfScopeError error.
func (OutOfScopeError) Error ¶
func (o OutOfScopeError) Error() string
Click to show internal directories.
Click to hide internal directories.