mirror of
https://github.com/pldubouilh/gossa.git
synced 2026-10-19 16:15:34 +00:00
Replace if-else chain in rpc function with switch statement
This commit is contained in:
committed by
Pierre Dubouilh
parent
7644c9f4d0
commit
23e9e6853f
@@ -231,11 +231,12 @@ func rpc(w http.ResponseWriter, r *http.Request) {
|
||||
check(err)
|
||||
json.Unmarshal(bodyBytes, &rpc)
|
||||
|
||||
if rpc.Call == "mkdirp" {
|
||||
switch rpc.Call {
|
||||
case "mkdirp":
|
||||
err = os.MkdirAll(enforcePath(rpc.Args[0]), os.ModePerm)
|
||||
} else if rpc.Call == "mv" {
|
||||
case "mv":
|
||||
err = os.Rename(enforcePath(rpc.Args[0]), enforcePath(rpc.Args[1]))
|
||||
} else if rpc.Call == "rm" {
|
||||
case "rm":
|
||||
err = os.RemoveAll(enforcePath(rpc.Args[0]))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user