application

package
v0.0.0-...-b97e90d Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2015 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	DB         gorm.DB
	CookieName string
	Options    *Option
	Store      store.Store
}

func New

func New(cookieName string, options *Option) (*Application, error)

func (*Application) Run

func (app *Application) Run(port int)

func (*Application) ServeHTTP

func (app *Application) ServeHTTP(h Handler) http.Handler

type Handler

type Handler func(app *Application, w http.ResponseWriter, r *Request)
var MeHandler Handler = func(app *Application, w http.ResponseWriter, r *Request) {
	fmt.Fprintf(w, fmt.Sprintf("Welcome %s", r.User.Username))
}
var UserHandler Handler = func(app *Application, w http.ResponseWriter, r *Request) {
	params := mux.Vars(r.Request)

	user := models.User{}

	app.DB.Where("username = ?", params["username"]).First(&user)

	fmt.Fprintf(w, fmt.Sprintf("Welcome %s", user.Username))
}

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(app *Application, w http.ResponseWriter, r *http.Request)

type Option

type Option struct {
	Database map[string]string
	Session  map[string]string
}

type Request

type Request struct {
	Request     *http.Request
	User        *models.User
	Session     *sessions.Session
	Application *Application
}

func (*Request) CurrentUser

func (req *Request) CurrentUser() (*models.User, error)

Jump to

Keyboard shortcuts

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