reformat code
This commit is contained in:
parent
27efd5384b
commit
83ed187dbc
18
garage.go
18
garage.go
@ -1,15 +1,15 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
garage "git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang"
|
||||||
"github.com/go-ldap/ldap/v3"
|
"github.com/go-ldap/ldap/v3"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
garage "git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang"
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func gadmin() (*garage.APIClient, context.Context) {
|
func gadmin() (*garage.APIClient, context.Context) {
|
||||||
@ -25,7 +25,6 @@ func gadmin() (*garage.APIClient, context.Context) {
|
|||||||
return client, ctx
|
return client, ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func grgCreateKey(name string) (*garage.KeyInfo, error) {
|
func grgCreateKey(name string) (*garage.KeyInfo, error) {
|
||||||
client, ctx := gadmin()
|
client, ctx := gadmin()
|
||||||
|
|
||||||
@ -110,7 +109,6 @@ func grgGetBucket(bid string) (*garage.BucketInfo, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func checkLoginAndS3(w http.ResponseWriter, r *http.Request) (*LoginStatus, *garage.KeyInfo, error) {
|
func checkLoginAndS3(w http.ResponseWriter, r *http.Request) (*LoginStatus, *garage.KeyInfo, error) {
|
||||||
login := checkLogin(w, r)
|
login := checkLogin(w, r)
|
||||||
if login == nil {
|
if login == nil {
|
||||||
@ -159,6 +157,7 @@ type webListView struct {
|
|||||||
Status *LoginStatus
|
Status *LoginStatus
|
||||||
Key *garage.KeyInfo
|
Key *garage.KeyInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleGarageWebsiteList(w http.ResponseWriter, r *http.Request) {
|
func handleGarageWebsiteList(w http.ResponseWriter, r *http.Request) {
|
||||||
login, s3key, err := checkLoginAndS3(w, r)
|
login, s3key, err := checkLoginAndS3(w, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -202,7 +201,7 @@ func handleGarageWebsiteNew(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
http.Redirect(w, r, "/garage/website/b/" + *binfo.Id, http.StatusFound)
|
http.Redirect(w, r, "/garage/website/b/"+*binfo.Id, http.StatusFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,6 +218,7 @@ type webInspectView struct {
|
|||||||
MaxSize int64
|
MaxSize int64
|
||||||
UsedSizePct float64
|
UsedSizePct float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleGarageWebsiteInspect(w http.ResponseWriter, r *http.Request) {
|
func handleGarageWebsiteInspect(w http.ResponseWriter, r *http.Request) {
|
||||||
login, s3key, err := checkLoginAndS3(w, r)
|
login, s3key, err := checkLoginAndS3(w, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -236,7 +236,7 @@ func handleGarageWebsiteInspect(w http.ResponseWriter, r *http.Request) {
|
|||||||
wc := binfo.GetWebsiteConfig()
|
wc := binfo.GetWebsiteConfig()
|
||||||
q := binfo.GetQuotas()
|
q := binfo.GetQuotas()
|
||||||
|
|
||||||
view := webInspectView {
|
view := webInspectView{
|
||||||
Status: login,
|
Status: login,
|
||||||
Key: s3key,
|
Key: s3key,
|
||||||
Bucket: binfo,
|
Bucket: binfo,
|
||||||
|
2
main.go
2
main.go
@ -105,7 +105,7 @@ func readConfig() ConfigFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getTemplate(name string) *template.Template {
|
func getTemplate(name string) *template.Template {
|
||||||
return template.Must(template.New("layout.html").Funcs(template.FuncMap {
|
return template.Must(template.New("layout.html").Funcs(template.FuncMap{
|
||||||
"contains": strings.Contains,
|
"contains": strings.Contains,
|
||||||
}).ParseFiles(
|
}).ParseFiles(
|
||||||
templatePath+"/layout.html",
|
templatePath+"/layout.html",
|
||||||
|
Loading…
Reference in New Issue
Block a user