controller

package
v0.0.0-...-a333e2e Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthRequired

func AuthRequired() http.HandlerFunc

AuthRequired returns a handler function which checks if user logged in or not.

func AuthTestHandler

func AuthTestHandler(w http.ResponseWriter, _ *http.Request) error

func CurrentName

func CurrentName(r *http.Request) string

CurrentName returns current user name who logged in.

func Error

func Error(w http.ResponseWriter, err error, code int)

func Flash

func Flash(r *http.Request, w http.ResponseWriter) []string

Flash returns flash message

func LoggedIn

func LoggedIn(r *http.Request) bool

LoggedIn returns if current session user is logged in or not.

func NewArticleHandler

func NewArticleHandler(w http.ResponseWriter, r *http.Request) error

func TXHandler

func TXHandler(db *sql.DB, f func(*sql.Tx) error) error

TXHandler is handler for working with transaction. This is wrapper function for commit and rollback.

Types

type Article

type Article struct {
	DB *sql.DB
}

Article is controller for requests to articles.

func (*Article) Delete

func (t *Article) Delete(w http.ResponseWriter, r *http.Request) error

Delete is endpont for deleting the document.

func (*Article) Edit

func (t *Article) Edit(w http.ResponseWriter, r *http.Request) error

Edit indicates edit page for certain article.

func (*Article) Get

func (t *Article) Get(w http.ResponseWriter, r *http.Request) error

Get returns specified article.

func (*Article) New

New works as endpoint to create new article. If successed, redirect to created one.

func (*Article) Root

func (t *Article) Root(w http.ResponseWriter, r *http.Request) error

Root indicates / path as top page.

func (*Article) Save

func (t *Article) Save(w http.ResponseWriter, r *http.Request) error

Save is endpoint for updating or creating documents. This accepts form request from browser. If id is specified, dealing with Update.

func (*Article) Update

func (t *Article) Update(w http.ResponseWriter, r *http.Request, m *model.Article) error

Update works for updating the specified article. After updating, redirect to one.

type User

type User struct {
	DB *sql.DB
}

User is controller for requests to user.

func (*User) LoginHandler

func (u *User) LoginHandler(w http.ResponseWriter, r *http.Request) error

func (*User) LogoutHandler

func (u *User) LogoutHandler(w http.ResponseWriter, r *http.Request) error

func (*User) SignupHandler

func (u *User) SignupHandler(w http.ResponseWriter, r *http.Request) error

Jump to

Keyboard shortcuts

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