func NewToken(userID bson.ObjectId) Token { return Token{ ID: bson.NewObjectId(), UserID: userID, Token: cryptoutils.RandToken(conf.TokenSize), CreatedAt: time.Now(), } }
func Logging(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { nw := negroni.NewResponseWriter(w) l := &negroni.Logger{ log.New(os.Stdout, fmt.Sprintf("api %s ", cryptoutils.RandToken(5)), 0), } l.ServeHTTP(nw, r, h.ServeHTTP) }) }
func NewToken(userID bson.ObjectId, forever bool) Token { token := Token{ ID: bson.NewObjectId(), UserID: userID, Token: cryptoutils.RandToken(conf.TokenSize), } if !forever { token.UpdatedAt = time.Now() } return token }