mirror of
https://github.com/restic/rest-server.git
synced 2025-12-06 17:15:45 -08:00
small refactoring
This commit is contained in:
4
auth.go
4
auth.go
@@ -20,9 +20,5 @@ func Authorize(r *http.Request) error {
|
||||
return errors.New("unknown user")
|
||||
}
|
||||
|
||||
if username != repo {
|
||||
return errors.New("unauthorized")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -20,12 +20,6 @@ func NewContext(path string) Context {
|
||||
return Context{path}
|
||||
}
|
||||
|
||||
// Creates the file structure of the Context
|
||||
func (c *Context) Init() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Context) Repository(name string) (Repository, error) {
|
||||
name, err := ParseRepositoryName(name)
|
||||
return Repository{filepath.Join(c.path, name)}, err
|
||||
|
||||
@@ -7,17 +7,11 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
context := Context{"/tmp/restic"}
|
||||
context := NewContext("/tmp/restic")
|
||||
|
||||
repo, _ := context.Repository("user")
|
||||
repo.Init()
|
||||
|
||||
errc := context.Init()
|
||||
if errc != nil {
|
||||
log.Println("context initialization failed")
|
||||
return
|
||||
}
|
||||
|
||||
router := Router{context}
|
||||
port := ":8000"
|
||||
log.Printf("start server on port %s", port)
|
||||
|
||||
Reference in New Issue
Block a user