Remove global vars

This commit is contained in:
Andrea Fazzi 2020-01-15 13:44:48 +01:00
parent 82de4b68fb
commit 50eaa518f5
3 changed files with 0 additions and 77 deletions

View file

@ -19,28 +19,6 @@ type UserToken struct {
UserID string
}
var (
// REMOVE
// signingKey = []byte(config.Config.Keys.JWTSigningKey)
// store = sessions.NewCookieStore([]byte(config.Config.Keys.CookieStoreKey))
// jwtCookie = jwtmiddleware.New(jwtmiddleware.Options{
// ValidationKeyGetter: func(token *jwt.Token) (interface{}, error) {
// return signingKey, nil
// },
// SigningMethod: jwt.SigningMethodHS256,
// Extractor: fromCookie,
// ErrorHandler: onError,
// })
// jwtHeader = jwtmiddleware.New(jwtmiddleware.Options{
// ValidationKeyGetter: func(token *jwt.Token) (interface{}, error) {
// return signingKey, nil
// },
// SigningMethod: jwt.SigningMethodHS256,
// })
)
func DefaultLogoutHandler(store *sessions.CookieStore) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
session, err := store.Get(r, "login-session")

View file

@ -66,9 +66,6 @@ func main() {
wait = false
}
// REMOVE
// orm.Use(db)
if conf.Orm.AutoMigrate {
log.Print("Automigrating...")
db.AutoMigrate()

View file

@ -48,11 +48,6 @@ type JsonResponse struct {
}
var (
// REMOVE
// store = sessions.NewCookieStore([]byte(config.Config.Keys.CookieStoreKey))
// currRenderer Renderer
// Render map[string]func(http.ResponseWriter, *http.Request, *sessions.CookieStore, interface{}, ...url.Values)
contentTypeToFormat = map[string]string{
"application/x-www-form-urlencoded": "html",
"text/html; charset=utf-8": "html",
@ -62,48 +57,6 @@ var (
}
)
func init() {
//REMOVE
// htmlRenderer, err := NewHTMLRenderer("templates/")
// if err != nil {
// panic(err)
// }
// jsonRenderer, err := NewJSONRenderer()
// if err != nil {
// panic(err)
// }
// csvRenderer, err := NewCSVRenderer()
// if err != nil {
// panic(err)
// }
// pdfRenderer, err := NewPDFRenderer()
// if err != nil {
// panic(err)
// }
// Render = make(map[string]func(http.ResponseWriter, *http.Request, *sessions.CookieStore, interface{}, ...url.Values))
// Render["html"] = func(w http.ResponseWriter, r *http.Request, store *sessions.CookieStore, data interface{}, options ...url.Values) {
// htmlRenderer.Render(w, r, store, data, options...)
// }
// Render["json"] = func(w http.ResponseWriter, r *http.Request, store *sessions.CookieStore, data interface{}, options ...url.Values) {
// jsonRenderer.Render(w, r, store, data, options...)
// }
// Render["csv"] = func(w http.ResponseWriter, r *http.Request, store *sessions.CookieStore, data interface{}, options ...url.Values) {
// csvRenderer.Render(w, r, data, options...)
// }
// Render["pdf"] = func(w http.ResponseWriter, r *http.Request, store *sessions.CookieStore, data interface{}, options ...url.Values) {
// pdfRenderer.Render(w, r, data, options...)
// }
}
func Query(values ...string) template.URL {
return query(values...)
}
@ -227,11 +180,6 @@ func NewHTMLRenderer(templatePath string) (*HTMLRenderer, error) {
return r, nil
}
// REMOVE
// func Use(r Renderer) {
// currRenderer = r
// }
func (rend *HTMLRenderer) writeError(w http.ResponseWriter, r *http.Request, data interface{}) {
var t *template.Template