1
0
Fork 0
mirror of https://github.com/Luzifer/cloudkeys-go.git synced 2024-11-08 14:10:05 +00:00

Fixed linter errors

This commit is contained in:
Knut Ahlers 2015-07-29 09:49:23 +02:00
parent e83e9100e4
commit dc3fb4df50
8 changed files with 19 additions and 12 deletions

View file

@ -15,6 +15,8 @@ type config struct {
CookieSigningKey string `flag:"cookie-authkey" description:"Key used to authenticate the session"`
CookieEncryptKey string `flag:"cookie-encryptkey" description:"Key used to encrypt the session"`
VersionAndQuit bool `flag:"version" default:"false" description:"Show version and quit"`
}
func (c config) ParsedStorage() (*url.URL, error) {

View file

@ -21,7 +21,7 @@ func httpHelper(f httpHelperFunc) http.HandlerFunc {
template, err := f(res, r, sess, &ctx)
if err != nil {
http.Error(res, err.Error(), http.StatusInternalServerError)
http.Error(res, "An error ocurred.", http.StatusInternalServerError)
fmt.Printf("ERR: %s\n", err)
return
}
@ -61,6 +61,6 @@ func simpleTemplateOutput(template string) httpHelperFunc {
}
}
func String(s string) *string {
func stringPointer(s string) *string {
return &s
}

View file

@ -19,7 +19,7 @@ func loginHandler(res http.ResponseWriter, r *http.Request, session *sessions.Se
if !storage.IsPresent(createUserFilename(username)) {
(*ctx)["error"] = true
return String("login.html"), nil
return stringPointer("login.html"), nil
}
userFileRaw, err := storage.Read(createUserFilename(username))
@ -34,7 +34,7 @@ func loginHandler(res http.ResponseWriter, r *http.Request, session *sessions.Se
if userFile.MetaData.Password != password {
(*ctx)["error"] = true
return String("login.html"), nil
return stringPointer("login.html"), nil
}
auth, ok := session.Values["authorizedAccounts"].(authorizedAccounts)

View file

@ -22,6 +22,11 @@ var (
)
func init() {
if cfg.VersionAndQuit {
fmt.Printf("cloudkeys-go %s\n", version)
os.Exit(0)
}
if _, err := cfg.ParsedStorage(); err != nil {
fmt.Printf("ERR: Please provide a valid storage URI\n")
os.Exit(1)

View file

@ -30,5 +30,5 @@ func overviewHandler(res http.ResponseWriter, r *http.Request, session *sessions
(*ctx)["authorized_accounts"] = frontendAccounts
(*ctx)["current_user_index"] = idx
return String("overview.html"), nil
return stringPointer("overview.html"), nil
}

View file

@ -18,12 +18,12 @@ func registerHandler(res http.ResponseWriter, r *http.Request, session *sessions
)
if username == "" || password == "" || password != passwordCheck {
return String("register.html"), nil
return stringPointer("register.html"), nil
}
if storage.IsPresent(createUserFilename(username)) {
(*ctx)["exists"] = true
return String("register.html"), nil
return stringPointer("register.html"), nil
}
d := dataObject{}
@ -35,7 +35,7 @@ func registerHandler(res http.ResponseWriter, r *http.Request, session *sessions
if err := storage.Write(createUserFilename(username), data); err == nil {
(*ctx)["created"] = true
return String("register.html"), nil
return stringPointer("register.html"), nil
}
return nil, err // TODO: Handle in-app?

View file

@ -11,7 +11,7 @@ import (
)
func init() {
registerStorage("local", NewLocalStorage)
registerStorage("local", newLocalStorage)
}
// LocalStorage implements a storage option for local file storage
@ -20,7 +20,7 @@ type LocalStorage struct {
}
// NewLocalStorage checks config, creates the path and initializes a LocalStorage
func NewLocalStorage(u *url.URL) (storageAdapter, error) {
func newLocalStorage(u *url.URL) (storageAdapter, error) {
p := u.Path[1:]
if len(p) == 0 {

View file

@ -14,7 +14,7 @@ import (
)
func init() {
registerStorage("s3", NewS3Storage)
registerStorage("s3", newS3Storage)
}
// S3Storage implements a storage option for Amazon S3
@ -25,7 +25,7 @@ type S3Storage struct {
}
// NewS3Storage checks config, creates the path and initializes a S3Storage
func NewS3Storage(u *url.URL) (storageAdapter, error) {
func newS3Storage(u *url.URL) (storageAdapter, error) {
return &S3Storage{
bucket: u.Host,
path: u.Path,