Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPServer ¶
type HTTPServer interface {
RenderTemplate(w http.ResponseWriter, r *http.Request, viewName, templateName string, title string, context interface{})
}
Interface used by ViewHandler
type MyHTTPServer ¶
type MyHTTPServer struct {
// contains filtered or unexported fields
}
func NewMyHTTPServer ¶
func NewMyHTTPServer(port int, basicAuthUsername string, basicAuthPassword string, templatesPath string, resourcesPath string, links map[string]string, iframeLinks map[string]string) *MyHTTPServer
New creates new instance of MyHTTPServer.
func (*MyHTTPServer) BasicAuthAuthenticate ¶
func (s *MyHTTPServer) BasicAuthAuthenticate(username, password string) (bool, error)
func (*MyHTTPServer) RegisterView ¶
func (s *MyHTTPServer) RegisterView(v View) error
RegisterView registers the given View on the server.
func (*MyHTTPServer) RenderTemplate ¶
func (s *MyHTTPServer) RenderTemplate(w http.ResponseWriter, r *http.Request, viewName, templateName string, title string, context interface{})
func (*MyHTTPServer) Run ¶
func (s *MyHTTPServer) Run()
type View ¶
type View interface { // Returns View name. GetName() string // Returns a mapping from template name to list of filenames under template // directory. These templates will be parsed by server at startup and can be // used by ViewHandle with RenderTemplate method of MyHTTPServer. GetTemplates() map[string][]string // Returns a mapping from url to ViewHandle that handles that URL. GetHandlers() map[string]ViewHandle // Returns a map from name to url. For each an entry will be created in // navigation pane. If the map is empty, no entries will be added. GetMenu() (string, map[string]string) }
Represents a portion of view logic for some stuff on the server. Usually contains common data used by multiple view handlers for that view.
type ViewHandle ¶
type ViewHandle interface { // Called by server upon receving the request. Returns context used for // rendering the web page or error. ServeHTTP(http.ResponseWriter, *http.Request, HTTPServer) }
Type representing a particular handler for a View.
func NewViewHandle ¶
func NewViewHandle(f func(http.ResponseWriter, *http.Request, HTTPServer)) ViewHandle
Click to show internal directories.
Click to hide internal directories.