handler

package
v0.0.0-...-ef76b7a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2014 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SessionName = "disgo"
)

Functions

func AdminIndex

func AdminIndex(w http.ResponseWriter, req *http.Request, app *App)

AdminIndex shows the overview of the admin interface with latest comments.

func ApproveComment

func ApproveComment(w http.ResponseWriter, req *http.Request, app *App)

ApproveComment allows admins to approve a comment by id.

func CreateComment

func CreateComment(w http.ResponseWriter, req *http.Request, app *App)

CreateComment validates and creates a new comment. It also saves the client's IP-adress to reduce spam.

func DestroyComment

func DestroyComment(w http.ResponseWriter, req *http.Request, app *App)

DestroyComment deletes a comment from the database by id.

func GetComments

func GetComments(w http.ResponseWriter, req *http.Request, app *App)

GetComments will display all comments for a given URL-parameter. If configured, it only displays approved comments.

func GetIndex

func GetIndex(w http.ResponseWriter, req *http.Request, app *App)

GetIndex shows a simple introduction.

func GetLogin

func GetLogin(w http.ResponseWriter, req *http.Request, app *App)

GetLogin shows the login form for the backend.

func GetRegister

func GetRegister(w http.ResponseWriter, req *http.Request, app *App)

GetRegister shows the register form.

func PostLogout

func PostLogout(w http.ResponseWriter, req *http.Request, app *App)

PostLogout logs the user out and redirects to the login page.

func PostSession

func PostSession(w http.ResponseWriter, req *http.Request, app *App)

PostLogin takes the email and password parameter and logs the user in if they are correct.

func PostUser

func PostUser(w http.ResponseWriter, req *http.Request, app *App)

PostUser will create a new user when no other users are in the database. If users are present, it will redirect to the login.

Types

type App

type App struct {
	Router       *mux.Router
	Db           *sql.DB
	Config       models.Config
	SessionStore sessions.Store
	Templates    map[string]*template.Template
	Notifier     *service.Notifier
}

App stores the context.

func NewApp

func NewApp(cfgPath string) (*App, error)

func (*App) ConnectDb

func (app *App) ConnectDb() error

Connect the DB and store the db pool reference.

func (*App) InitSession

func (app *App) InitSession()

Initialize the session.

func (*App) LoadConfig

func (app *App) LoadConfig(path string) error

Load the config.

func (*App) ParseTemplates

func (app *App) ParseTemplates() error

Parse and store all templates.

func (*App) SetRoutes

func (app *App) SetRoutes()

Set all routes for the app.

Notes

Bugs

  • Use migrations instead.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL