model

package
v0.0.0-...-ac04cce Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2016 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SecretKey = "somekey"

Variable contain SecretKey. SecretKey should be loaded from secret key file from Config.

View Source
var TokenLifetime = int64(10)

Time to live valid token. After this period - token will be expired.

Functions

func InitToken

func InitToken(config cfg.Config)

Initialize token and time to live.

func LoadKey

func LoadKey(config cfg.Config) (string, error)

Load token from file. File must be specified in config.

func TokenGenerate

func TokenGenerate(login, user_id string) string

Generate new token

P.S token is JWT standart.

func TokenParse

func TokenParse(myToken string) (string, string, error)

Parse Token from request.

Types

type City

type City struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	TimeZone int64  `json:"time_zone"`
}

type Error

type Error struct {
	Type    string `json:"type"`    // The type of error returned. Can be … TODO.
	Message string `json:"message"` // optional	A human-readable message giving more details about the error. If something needs to be shown to end-users, this should be it.
	Param   string `json:"param"`   // The parameter the error relates to if the error is parameter-specific.
}

type Login

type Login struct {
	Login    string `json:"login" binding:"required"`
	Password string `json:"password" binding:"required"`
}

type User

type User struct {
	ID       int64  `json:"id"`
	Login    string `json:"login" binding:"required"`
	Password string `json:"password" binding:"required"`
	Email    string `json:"email" binding:"required"`
	Cities   []City `json:"cities"`
}

Jump to

Keyboard shortcuts

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