Skip to content
This repository was archived by the owner on Mar 8, 2023. It is now read-only.

Commit ae270ee

Browse files
committed
Add DELETE method on /secrets/raw
1 parent 00a0401 commit ae270ee

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

pkg/restproxy/rest_proxy.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,27 @@ func (p *restProxy) handleSecret(w http.ResponseWriter, r *http.Request) {
125125
}
126126

127127
w.WriteHeader(http.StatusCreated)
128+
case "DELETE":
129+
err := p.client.Secrets().Delete(path)
130+
if err != nil {
131+
var errCode int
132+
133+
if err, ok := err.(errio.PublicStatusError); ok {
134+
errCode = err.StatusCode
135+
}
136+
137+
if errCode == 0 {
138+
errCode = http.StatusInternalServerError
139+
}
140+
141+
w.WriteHeader(errCode)
142+
io.WriteString(w, err.Error())
143+
return
144+
}
145+
146+
w.WriteHeader(http.StatusOK)
128147
default:
129-
w.Header().Add("Allow", "GET, POST")
148+
w.Header().Add("Allow", "GET, POST, DELETE")
130149
w.WriteHeader(http.StatusMethodNotAllowed)
131150
}
132151
}

0 commit comments

Comments
 (0)