Format the source file
This commit is contained in:
parent
d69640894d
commit
8f7e8d2c73
1 changed files with 198 additions and 197 deletions
33
main.go
33
main.go
|
@ -2,15 +2,15 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"fmt"
|
||||
"os"
|
||||
"io/fs"
|
||||
"time"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/webdav"
|
||||
|
||||
|
@ -21,6 +21,7 @@ import (
|
|||
)
|
||||
|
||||
type bagageCtxKey string
|
||||
|
||||
const garageEntry = bagageCtxKey("garage")
|
||||
|
||||
type garageCtx struct {
|
||||
|
@ -45,18 +46,18 @@ func main() {
|
|||
}
|
||||
|
||||
//http.Handle("/", srv)
|
||||
http.HandleFunc(pathPrefix + "/", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.HandleFunc(pathPrefix+"/", func(w http.ResponseWriter, r *http.Request) {
|
||||
username, password, ok := r.BasicAuth()
|
||||
|
||||
if !ok {
|
||||
NotAuthorized(w,r)
|
||||
NotAuthorized(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
ldapSock, err := ldap.Dial("tcp", "127.0.0.1:1389")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
InternalError(w,r)
|
||||
InternalError(w, r)
|
||||
return
|
||||
}
|
||||
defer ldapSock.Close()
|
||||
|
@ -66,7 +67,7 @@ func main() {
|
|||
err = ldapSock.Bind(userDn, password)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
NotAuthorized(w,r)
|
||||
NotAuthorized(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -85,13 +86,13 @@ func main() {
|
|||
sr, err := ldapSock.Search(searchRequest)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
InternalError(w,r)
|
||||
InternalError(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
if len(sr.Entries) != 1 {
|
||||
log.Println("Wrong number of LDAP entries, expected 1, got", len(sr.Entries))
|
||||
InternalError(w,r)
|
||||
InternalError(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -100,7 +101,7 @@ func main() {
|
|||
|
||||
if access_key == "" || secret_key == "" {
|
||||
log.Println("Either access key or secret key is missing in LDAP for ", userDn)
|
||||
InternalError(w,r)
|
||||
InternalError(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -110,7 +111,7 @@ func main() {
|
|||
})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
InternalError(w,r)
|
||||
InternalError(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -146,7 +147,7 @@ func InternalError(w http.ResponseWriter, r *http.Request) {
|
|||
Else
|
||||
return obj
|
||||
*/
|
||||
type GarageFS struct {}
|
||||
type GarageFS struct{}
|
||||
|
||||
func NewGarageFS() *GarageFS {
|
||||
grg := new(GarageFS)
|
||||
|
@ -246,7 +247,7 @@ func (gf *GarageFile) readDirChild(count int, bucket, prefix string) ([]fs.FileI
|
|||
Recursive: false,
|
||||
})
|
||||
|
||||
entries := make([]fs.FileInfo,0)
|
||||
entries := make([]fs.FileInfo, 0)
|
||||
for object := range objs_info {
|
||||
if object.Err != nil {
|
||||
return nil, object.Err
|
||||
|
|
Loading…
Reference in a new issue