chore: idea: unify http responses further (#941)

This commit is contained in:
Garrett Delfosse
2022-04-12 10:17:33 -05:00
committed by GitHub
parent 4f0f216015
commit d9d4599ba9
16 changed files with 59 additions and 105 deletions

View File

@ -4,8 +4,6 @@ import (
"fmt"
"net/http"
"github.com/go-chi/render"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/gitsshkey"
"github.com/coder/coder/coderd/httpapi"
@ -44,8 +42,7 @@ func (api *api) regenerateGitSSHKey(rw http.ResponseWriter, r *http.Request) {
return
}
render.Status(r, http.StatusOK)
render.JSON(rw, r, codersdk.GitSSHKey{
httpapi.Write(rw, http.StatusOK, codersdk.GitSSHKey{
UserID: newKey.UserID,
CreatedAt: newKey.CreatedAt,
UpdatedAt: newKey.UpdatedAt,
@ -64,8 +61,7 @@ func (api *api) gitSSHKey(rw http.ResponseWriter, r *http.Request) {
return
}
render.Status(r, http.StatusOK)
render.JSON(rw, r, codersdk.GitSSHKey{
httpapi.Write(rw, http.StatusOK, codersdk.GitSSHKey{
UserID: gitSSHKey.UserID,
CreatedAt: gitSSHKey.CreatedAt,
UpdatedAt: gitSSHKey.UpdatedAt,
@ -108,8 +104,7 @@ func (api *api) agentGitSSHKey(rw http.ResponseWriter, r *http.Request) {
return
}
render.Status(r, http.StatusOK)
render.JSON(rw, r, codersdk.AgentGitSSHKey{
httpapi.Write(rw, http.StatusOK, codersdk.AgentGitSSHKey{
PrivateKey: gitSSHKey.PrivateKey,
})
}