mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 07:33:21 +00:00
small refactoring
This commit is contained in:
parent
a6f9e71f95
commit
b4d923ab26
3 changed files with 1 additions and 17 deletions
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue