Skip to content

Commit 205ea93

Browse files
committed
chore: code review
1 parent 7d627c5 commit 205ea93

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

coderd/workspaces.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,28 @@ func (api *api) workspace(rw http.ResponseWriter, r *http.Request) {
3232
}
3333

3434
// The `deleted` query parameter (which defaults to `false`) MUST match the
35-
// `deleted` field on the workspace otherwise you will get a 410 Gone.
35+
// `Deleted` field on the workspace otherwise you will get a 410 Gone.
3636
var (
37-
deletedStr = r.URL.Query().Get("deleted")
38-
deleted = false
37+
deletedStr = r.URL.Query().Get("deleted")
38+
showDeleted = false
3939
)
4040
if deletedStr != "" {
4141
var err error
42-
deleted, err = strconv.ParseBool(deletedStr)
42+
showDeleted, err = strconv.ParseBool(deletedStr)
4343
if err != nil {
4444
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
4545
Message: fmt.Sprintf("invalid bool for 'deleted' query param: %s", err),
4646
})
4747
return
4848
}
4949
}
50-
if workspace.Deleted != deleted {
51-
if workspace.Deleted {
52-
httpapi.Write(rw, http.StatusGone, httpapi.Response{
53-
Message: fmt.Sprintf("workspace %q was deleted, you can view this workspace by specifying '?deleted=true' and trying again", workspace.ID.String()),
54-
})
55-
return
56-
}
57-
50+
if workspace.Deleted && !showDeleted {
51+
httpapi.Write(rw, http.StatusGone, httpapi.Response{
52+
Message: fmt.Sprintf("workspace %q was deleted, you can view this workspace by specifying '?deleted=true' and trying again", workspace.ID.String()),
53+
})
54+
return
55+
}
56+
if !workspace.Deleted && showDeleted {
5857
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
5958
Message: fmt.Sprintf("workspace %q is not deleted, please remove '?deleted=true' and try again", workspace.ID.String()),
6059
})

0 commit comments

Comments
 (0)