Documentation
¶
Overview ¶
Package responder contains all the general functionality necessary for responding to a given server request: template setup, user auth checks, rendering of pages to an http.ResponseWriter
Index ¶
- Variables
- func GetUserIP(req *http.Request) string
- func GetUserLogin(w http.ResponseWriter, req *http.Request) string
- func HTMLComment(s string) template.HTML
- func InitRootTemplate(templatePath string)
- func MustHavePrivilege(priv *user.Privilege, f http.HandlerFunc) http.Handler
- type GenericVars
- type PageVars
- type Responder
Constants ¶
This section is empty.
Variables ¶
var ( // Layout holds the base site layout template. Handlers should clone and use // this for parsing their specific page templates Layout *tmpl.TRoot // InsufficientPrivileges is a simple page to declare to a user they are not // allowed to visit a certain page or perform a certain action InsufficientPrivileges *tmpl.Template // Home (for now) is a very simple static welcome page Home *tmpl.Template // Empty holds a simple blank page for rendering the header/footer and often // a simple alert-style message Empty *tmpl.Template )
Functions ¶
func GetUserIP ¶
GetUserIP returns the IP address from Apache. NOTE: This definitely won't work when the app is exposed directly!
func GetUserLogin ¶
func GetUserLogin(w http.ResponseWriter, req *http.Request) string
GetUserLogin returns the Apache-auth user or the debuguser argument if settings.DEBUG is true
func HTMLComment ¶
HTMLComment forces an HTML comment into the source (since Go templates strip these)
func InitRootTemplate ¶
func InitRootTemplate(templatePath string)
InitRootTemplate sets up pre-parsed template data in Root
func MustHavePrivilege ¶
MustHavePrivilege denies access to pages if there's no logged-in user, or there is a user but the user isn't allowed to perform a particular action
Types ¶
type GenericVars ¶
type GenericVars map[string]interface{}
GenericVars holds anything specialized that doesn't make sense to have in PageVars
type PageVars ¶
type PageVars struct { Title string Version string Alert template.HTML Info template.HTML User *user.User Data GenericVars }
PageVars is the generic list of data all pages may need, and the catch-all "Data" map for specialized one-off data
type Responder ¶
type Responder struct { Writer http.ResponseWriter Request *http.Request Vars *PageVars }
Responder wraps common response logic
func Response ¶
func Response(w http.ResponseWriter, req *http.Request) *Responder
Response generates a Responder with basic data all pages will need: request, response writer, and user
func (*Responder) Audit ¶
Audit stores an audit log in the database and logs to the command line if the database audit fails