command line args

This commit is contained in:
Chapuis Bertil 2015-09-07 15:29:24 +02:00
parent 436de7f687
commit 738e78c439
6 changed files with 110 additions and 74 deletions

View file

@ -11,13 +11,13 @@ type Handler func(w http.ResponseWriter, r *http.Request, c *Context)
func HeadConfig(w http.ResponseWriter, r *http.Request, c *Context) {
uri := r.RequestURI
name, errrn := RepositoryName(uri)
if errrn != nil {
name, err := RepositoryName(uri)
if err != nil {
http.NotFound(w, r)
return
}
repo, errr := c.Repository(name)
if errr != nil {
repo, err := c.Repository(name)
if err != nil {
http.NotFound(w, r)
return
}
@ -29,18 +29,18 @@ func HeadConfig(w http.ResponseWriter, r *http.Request, c *Context) {
func GetConfig(w http.ResponseWriter, r *http.Request, c *Context) {
uri := r.RequestURI
name, errrn := RepositoryName(uri)
if errrn != nil {
name, err := RepositoryName(uri)
if err != nil {
http.NotFound(w, r)
return
}
repo, errr := c.Repository(name)
if errr != nil {
repo, err := c.Repository(name)
if err != nil {
http.NotFound(w, r)
return
}
config, errrc := repo.ReadConfig()
if errrc != nil {
config, err := repo.ReadConfig()
if err != nil {
http.NotFound(w, r)
return
}
@ -49,37 +49,37 @@ func GetConfig(w http.ResponseWriter, r *http.Request, c *Context) {
func PostConfig(w http.ResponseWriter, r *http.Request, c *Context) {
uri := r.RequestURI
name, errrn := RepositoryName(uri)
if errrn != nil {
name, err := RepositoryName(uri)
if err != nil {
http.NotFound(w, r)
return
}
repo, errr := c.Repository(name)
if errr != nil {
repo, err := c.Repository(name)
if err != nil {
http.NotFound(w, r)
return
}
config, errc := ioutil.ReadAll(r.Body)
config, err := ioutil.ReadAll(r.Body)
if err != nil {
http.NotFound(w, r)
return
}
errc := repo.WriteConfig(config)
if errc != nil {
http.NotFound(w, r)
return
}
errwc := repo.WriteConfig(config)
if errwc != nil {
http.NotFound(w, r)
return
}
}
func ListBlob(w http.ResponseWriter, r *http.Request, c *Context) {
uri := r.RequestURI
name, errrn := RepositoryName(uri)
if errrn != nil {
name, err := RepositoryName(uri)
if err != nil {
http.NotFound(w, r)
return
}
repo, errr := c.Repository(name)
if errr != nil {
repo, err := c.Repository(name)
if err != nil {
http.NotFound(w, r)
return
}
@ -88,13 +88,13 @@ func ListBlob(w http.ResponseWriter, r *http.Request, c *Context) {
http.NotFound(w, r)
return
}
blobs, errb := repo.ListBlob(bt)
if errb != nil {
blobs, err := repo.ListBlob(bt)
if err != nil {
http.NotFound(w, r)
return
}
json, errj := json.Marshal(blobs)
if errj != nil {
json, err := json.Marshal(blobs)
if err != nil {
http.NotFound(w, r)
return
}
@ -103,13 +103,13 @@ func ListBlob(w http.ResponseWriter, r *http.Request, c *Context) {
func HeadBlob(w http.ResponseWriter, r *http.Request, c *Context) {
uri := r.RequestURI
name, errrn := RepositoryName(uri)
if errrn != nil {
name, err := RepositoryName(uri)
if err != nil {
http.NotFound(w, r)
return
}
repo, errr := c.Repository(name)
if errr != nil {
repo, err := c.Repository(name)
if err != nil {
http.NotFound(w, r)
return
}
@ -131,13 +131,13 @@ func HeadBlob(w http.ResponseWriter, r *http.Request, c *Context) {
func GetBlob(w http.ResponseWriter, r *http.Request, c *Context) {
uri := r.RequestURI
name, errrn := RepositoryName(uri)
if errrn != nil {
name, err := RepositoryName(uri)
if err != nil {
http.NotFound(w, r)
return
}
repo, errr := c.Repository(name)
if errr != nil {
repo, err := c.Repository(name)
if err != nil {
http.NotFound(w, r)
return
}
@ -151,8 +151,8 @@ func GetBlob(w http.ResponseWriter, r *http.Request, c *Context) {
http.NotFound(w, r)
return
}
blob, errb := repo.ReadBlob(bt, id)
if errb != nil {
blob, errr := repo.ReadBlob(bt, id)
if errr != nil {
http.NotFound(w, r)
return
}
@ -161,13 +161,13 @@ func GetBlob(w http.ResponseWriter, r *http.Request, c *Context) {
func PostBlob(w http.ResponseWriter, r *http.Request, c *Context) {
uri := r.RequestURI
name, errrn := RepositoryName(uri)
if errrn != nil {
name, err := RepositoryName(uri)
if err != nil {
http.NotFound(w, r)
return
}
repo, errr := c.Repository(name)
if errr != nil {
repo, err := c.Repository(name)
if err != nil {
http.NotFound(w, r)
return
}
@ -181,13 +181,13 @@ func PostBlob(w http.ResponseWriter, r *http.Request, c *Context) {
http.NotFound(w, r)
return
}
blob, errb := ioutil.ReadAll(r.Body)
if errb != nil {
blob, err := ioutil.ReadAll(r.Body)
if err != nil {
http.NotFound(w, r)
return
}
errwb := repo.WriteBlob(bt, id, blob)
if errwb != nil {
errw := repo.WriteBlob(bt, id, blob)
if errw != nil {
http.NotFound(w, r)
return
}
@ -196,13 +196,13 @@ func PostBlob(w http.ResponseWriter, r *http.Request, c *Context) {
func DeleteBlob(w http.ResponseWriter, r *http.Request, c *Context) {
uri := r.RequestURI
name, errrn := RepositoryName(uri)
if errrn != nil {
name, err := RepositoryName(uri)
if err != nil {
http.NotFound(w, r)
return
}
repo, errr := c.Repository(name)
if errr != nil {
repo, err := c.Repository(name)
if err != nil {
http.NotFound(w, r)
return
}