Skip to content

Commit 62766ad

Browse files
viveksynghalexellis
authored andcommitted
Update status code for CRUD APIs
This commit updates the status code from 200 to 202 for create, update or delete APIs. Fixes: openfaas#220 Signed-off-by: Vivek Singh <[email protected]>
1 parent f06156c commit 62766ad

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

handlers/delete.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ func MakeDeleteHandler(functionNamespace string, clientset *kubernetes.Clientset
5959
w.Write([]byte("Not a function: " + request.FunctionName))
6060
return
6161
}
62+
63+
w.WriteHeader(http.StatusAccepted)
6264
}
6365
}
6466

handlers/replicas.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func MakeReplicaUpdater(functionNamespace string, clientset *kubernetes.Clientse
6363
return
6464
}
6565

66+
w.WriteHeader(http.StatusAccepted)
6667
}
6768
}
6869

@@ -81,13 +82,13 @@ func MakeReplicaReader(functionNamespace string, clientset *kubernetes.Clientset
8182
}
8283

8384
if function == nil {
84-
w.WriteHeader(404)
85+
w.WriteHeader(http.StatusNotFound)
8586
return
8687
}
8788

8889
functionBytes, _ := json.Marshal(function)
8990
w.Header().Set("Content-Type", "application/json")
90-
w.WriteHeader(200)
91+
w.WriteHeader(http.StatusOK)
9192
w.Write(functionBytes)
9293
}
9394
}

handlers/update.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func MakeUpdateHandler(functionNamespace string, clientset *kubernetes.Clientset
3838
w.WriteHeader(status)
3939
w.Write([]byte(err.Error()))
4040
}
41+
42+
w.WriteHeader(http.StatusAccepted)
4143
}
4244
}
4345

@@ -118,7 +120,7 @@ func updateDeploymentSpec(
118120
return updateErr, http.StatusInternalServerError
119121
}
120122

121-
return nil, http.StatusOK
123+
return nil, http.StatusAccepted
122124
}
123125

124126
func updateService(
@@ -146,5 +148,5 @@ func updateService(
146148
return updateErr, http.StatusInternalServerError
147149
}
148150

149-
return nil, http.StatusOK
151+
return nil, http.StatusAccepted
150152
}

0 commit comments

Comments
 (0)