Documentation ¶
Index ¶
- Variables
- func DisplayPage(w io.Writer, path string, page interface{})
- func DisplayText(hc *HttpContext, w io.Writer, text string)
- func GetPage(path string, page interface{}) io.Reader
- func GetPageContent(path string, page interface{}) (string, error)
- func InitMailer(smtpConfig *EmailSMTPConfig)
- func InitTmpl()
- type EmailCtx
- type EmailSMTPConfig
- type HttpContext
- func (hc *HttpContext) AddFlash(flash string)
- func (hc *HttpContext) ClearSession()
- func (hc *HttpContext) GetFlashes() []string
- func (hc *HttpContext) GetSessionData(key string) interface{}
- func (hc *HttpContext) RedirectAfterAuth(flash string) bool
- func (hc *HttpContext) RedirectUnlessAuthed(flash string) bool
- func (hc *HttpContext) SetSessionData(key string, value interface{})
- type Page
Constants ¶
This section is empty.
Variables ¶
var ( // SessionName .. SessionName = "_kinli" // can be seen in the cookies list // HomePathNonAuthed redirection for NonLoggedInUser HomePathNonAuthed = "/home" // HomePathAuthed redirection for LoggedInUser HomePathAuthed = "/" // SessionStore interface to will be used SessionStore sessions.Store )
var ( // PathTemplate is the template/ dir . default is tmpl/ PathTemplate = "tmpl/" // PathPartialTemplate is the relative path for partials/ directory. default is tmpl/partials/ PathPartialTemplate = "tmpl/partials/" // CacheMode is true to cache templates. set to false during development CacheMode = true // ViewFuncs supports extra functions which user can use in views ViewFuncs template.FuncMap )
var ( // ClientConfig can be set once so that all pages can use that static information ClientConfig map[string]string )
hc.isAuthed() { userInfo = &Authentication{}
var IsAuthed = isAuthed
IsAuthed is used to verify if a user is logged in or not can be overriden with your own business logic
Functions ¶
func DisplayPage ¶
DisplayPage exposes writer path is the name of the file without ".html" page can be the structure that you can access in the view. Page struct is recommended or inherit the Page struct
func DisplayText ¶
func DisplayText(hc *HttpContext, w io.Writer, text string)
DisplayText takes in the context for creating a NewPage and displays the text as page Uses "_text.html" file in your template directory
func GetPageContent ¶
GetPageContent gets the page content as string
func InitMailer ¶
func InitMailer(smtpConfig *EmailSMTPConfig)
InitMailer can be initialised only once all future calls will be ignored
Types ¶
type EmailCtx ¶
type EmailCtx struct { From *mail.Address To []*mail.Address Cc []*mail.Address Bcc []*mail.Address Subject string PlainBody string HTMLBody string // optional headers that need to be sent Headers map[string]string }
EmailCtx which needs to be set to send the email
type EmailSMTPConfig ¶
EmailSMTPConfig passed for initialisation
type HttpContext ¶
type HttpContext struct { W http.ResponseWriter R *http.Request }
HttpContext .. is the current context
func (*HttpContext) AddFlash ¶
func (hc *HttpContext) AddFlash(flash string)
func (*HttpContext) ClearSession ¶
func (hc *HttpContext) ClearSession()
ClearSession logs out the user by deleting all session data
func (*HttpContext) GetFlashes ¶
func (hc *HttpContext) GetFlashes() []string
GetFlashes gets the list of flashes and flushes as well
func (*HttpContext) GetSessionData ¶
func (hc *HttpContext) GetSessionData(key string) interface{}
GetSessionData can be used to retrieve the data retrieving should be of the format data, ok := val.(*Data)
func (*HttpContext) RedirectAfterAuth ¶
func (hc *HttpContext) RedirectAfterAuth(flash string) bool
RedirectAfterAuth will redirect user immediately after authentication returns true if redirected, false if not
func (*HttpContext) RedirectUnlessAuthed ¶
func (hc *HttpContext) RedirectUnlessAuthed(flash string) bool
RedirectUnlessAuthed redirects if the user is not logged in returns true if redirected, false if not
func (*HttpContext) SetSessionData ¶
func (hc *HttpContext) SetSessionData(key string, value interface{})
setSessionData sets a key/value into a session and saves it value should be registered first with gob.Register(&Data{}) should be sending data should be of the format ("data", &Data{}) retrieving should be of the format data, ok := val.(*Data)
type Page ¶
type Page struct { // Title of the page Title string // TODO make this richer context // User information that can be accessed on any page User interface{} // List of Flash Messages Flashes []string // List of flash messages // Context is the Main Content of the page Context interface{} // Data not part of the context (one timers info) Data map[string]string // ClientConfig contains constant stuff like GoogleAnalytics attributes etc., ClientConfig map[string]string }
Page has all information to be fillable