controller

package
Version: v0.0.0-...-1cbb4d5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthRequired

func AuthRequired() gin.HandlerFunc

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

func CurrentName

func CurrentName(c *gin.Context) string

CurrentName returns current user name who logged in.

func LoggedIn

func LoggedIn(c *gin.Context) bool

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

func TXHandler

func TXHandler(c *gin.Context, db *sql.DB, f func(*sql.Tx) 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
	ES     *elastic.Client
	Fluent *fluent.Fluent
}

Article is controller for requests to articles.

func (*Article) Delete

func (t *Article) Delete(c *gin.Context)

Delete is endpont for deleting the document.

func (*Article) Edit

func (t *Article) Edit(c *gin.Context)

Edit indicates edit page for certain article.

func (*Article) Get

func (t *Article) Get(c *gin.Context)

Get returns specified article.

func (*Article) New

func (t *Article) New(c *gin.Context, m *model.Article)

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

func (*Article) Root

func (t *Article) Root(c *gin.Context)

Root indicates / path as top page.

func (*Article) Save

func (t *Article) Save(c *gin.Context)

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

func (*Article) Search

func (t *Article) Search(c *gin.Context)

TODO search document by elasticsearch

func (*Article) Update

func (t *Article) Update(c *gin.Context, m *model.Article)

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

type SearchLog

type SearchLog struct {
	Query  string `msg:"query"`
	UserID int64  `msg:"user_id"`
}

type User

type User struct {
	DB *sql.DB
}

User is controller for requests to user.

func (*User) Login

func (u *User) Login(c *gin.Context)

Login try login.

func (*User) Logout

func (u *User) Logout(c *gin.Context)

Logout makes user logged out.

func (*User) SignUp

func (u *User) SignUp(c *gin.Context)

SignUp makes user signup.

Jump to

Keyboard shortcuts

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