Пример #1
0
func init() {
	var err error
	Connection, err = sql.Open("sqlite3", option.String("dbpath"))

	if err != nil {
		logrus.WithFields(logrus.Fields{
			"Path": option.String("dbpath"),
		}).Error(err)
	}
}
Пример #2
0
func Patch() {
	errors, ok := migrate.UpSync("sqlite3://"+option.String("dbpath"), "migrations")

	if !ok {
		for _, err := range errors {
			logrus.WithFields(logrus.Fields{
				"Path": option.String("dbpath"),
			}).Error(err.Error())
		}
	}
}
Пример #3
0
func CheckPatch() uint64 {
	patch, _ := migrate.Version("sqlite3://"+option.String("dbpath"), "migrations")

	return patch
}
Пример #4
0
func hashpassword(password string) string {
	hash := md5.Sum([]byte(password + option.String("passwordsalt")))
	password = string(hash[:])
	return password
}
Пример #5
0
package server

import (
	"github.com/ospokemon/ospokemon/option"
	"net/http"
)

var fileserver = http.FileServer(http.Dir(option.String("webpath")))

var PageHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	if s := readsession(r); s != nil {
		s.Refresh()
	}

	fileserver.ServeHTTP(w, r)
})
Пример #6
0
func Launch() {
	routes()
	go PollSessionExpire()
	e := http.ListenAndServe(":"+option.String("port"), nil)
	logrus.Error(e)
}