refactor: more implementation to refactor
This commit is contained in:
parent
bfd83f35a3
commit
ba684bd149
1 changed files with 13 additions and 4 deletions
|
|
@ -118,9 +118,9 @@ func (s *Service) CreateProfile() http.HandlerFunc {
|
||||||
profile *Profile `json:"profile"`
|
profile *Profile `json:"profile"`
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
body []byte
|
body, contents []byte
|
||||||
in input
|
in input
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
body, err = io.ReadAll(r.Body)
|
body, err = io.ReadAll(r.Body)
|
||||||
|
|
@ -136,8 +136,17 @@ func (s *Service) CreateProfile() http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// serialize just the profile part
|
||||||
|
contents, err = json.Marshal(in.profile)
|
||||||
|
if err != nil {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// create a new profile on disk
|
// create a new profile on disk
|
||||||
os.WriteFile()
|
err = os.WriteFile(in.path, contents, os.ModePerm)
|
||||||
|
if err != nil {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue