77 "net/http"
88
99 "github.com/go-chi/chi/v5"
10- "github.com/go-chi/render"
1110 "github.com/google/uuid"
1211 "github.com/moby/moby/pkg/namesgenerator"
1312 "golang.org/x/xerrors"
@@ -20,8 +19,7 @@ import (
2019
2120func (* api ) organization (rw http.ResponseWriter , r * http.Request ) {
2221 organization := httpmw .OrganizationParam (r )
23- render .Status (r , http .StatusOK )
24- render .JSON (rw , r , convertOrganization (organization ))
22+ httpapi .Write (rw , http .StatusOK , convertOrganization (organization ))
2523}
2624
2725func (api * api ) provisionerDaemonsByOrganization (rw http.ResponseWriter , r * http.Request ) {
@@ -38,8 +36,7 @@ func (api *api) provisionerDaemonsByOrganization(rw http.ResponseWriter, r *http
3836 if daemons == nil {
3937 daemons = []database.ProvisionerDaemon {}
4038 }
41- render .Status (r , http .StatusOK )
42- render .JSON (rw , r , daemons )
39+ httpapi .Write (rw , http .StatusOK , daemons )
4340}
4441
4542// Creates a new version of a template. An import job is queued to parse the storage method provided.
@@ -147,8 +144,7 @@ func (api *api) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *ht
147144 return
148145 }
149146
150- render .Status (r , http .StatusCreated )
151- render .JSON (rw , r , convertTemplateVersion (templateVersion , convertProvisionerJob (provisionerJob )))
147+ httpapi .Write (rw , http .StatusCreated , convertTemplateVersion (templateVersion , convertProvisionerJob (provisionerJob )))
152148}
153149
154150// Create a new template in an organization.
@@ -252,8 +248,7 @@ func (api *api) postTemplatesByOrganization(rw http.ResponseWriter, r *http.Requ
252248 return
253249 }
254250
255- render .Status (r , http .StatusCreated )
256- render .JSON (rw , r , template )
251+ httpapi .Write (rw , http .StatusCreated , template )
257252}
258253
259254func (api * api ) templatesByOrganization (rw http.ResponseWriter , r * http.Request ) {
@@ -284,8 +279,8 @@ func (api *api) templatesByOrganization(rw http.ResponseWriter, r *http.Request)
284279 })
285280 return
286281 }
287- render . Status ( r , http . StatusOK )
288- render . JSON (rw , r , convertTemplates (templates , workspaceCounts ))
282+
283+ httpapi . Write (rw , http . StatusOK , convertTemplates (templates , workspaceCounts ))
289284}
290285
291286func (api * api ) templateByOrganizationAndName (rw http.ResponseWriter , r * http.Request ) {
@@ -325,8 +320,7 @@ func (api *api) templateByOrganizationAndName(rw http.ResponseWriter, r *http.Re
325320 count = uint32 (workspaceCounts [0 ].Count )
326321 }
327322
328- render .Status (r , http .StatusOK )
329- render .JSON (rw , r , convertTemplate (template , count ))
323+ httpapi .Write (rw , http .StatusOK , convertTemplate (template , count ))
330324}
331325
332326// convertOrganization consumes the database representation and outputs an API friendly representation.
0 commit comments