7
7
"net/http"
8
8
9
9
"github.com/go-chi/chi/v5"
10
- "github.com/go-chi/render"
11
10
"github.com/google/uuid"
12
11
"github.com/moby/moby/pkg/namesgenerator"
13
12
"golang.org/x/xerrors"
@@ -20,8 +19,7 @@ import (
20
19
21
20
func (* api ) organization (rw http.ResponseWriter , r * http.Request ) {
22
21
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 ))
25
23
}
26
24
27
25
func (api * api ) provisionerDaemonsByOrganization (rw http.ResponseWriter , r * http.Request ) {
@@ -38,8 +36,7 @@ func (api *api) provisionerDaemonsByOrganization(rw http.ResponseWriter, r *http
38
36
if daemons == nil {
39
37
daemons = []database.ProvisionerDaemon {}
40
38
}
41
- render .Status (r , http .StatusOK )
42
- render .JSON (rw , r , daemons )
39
+ httpapi .Write (rw , http .StatusOK , daemons )
43
40
}
44
41
45
42
// 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
147
144
return
148
145
}
149
146
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 )))
152
148
}
153
149
154
150
// Create a new template in an organization.
@@ -252,8 +248,7 @@ func (api *api) postTemplatesByOrganization(rw http.ResponseWriter, r *http.Requ
252
248
return
253
249
}
254
250
255
- render .Status (r , http .StatusCreated )
256
- render .JSON (rw , r , template )
251
+ httpapi .Write (rw , http .StatusCreated , template )
257
252
}
258
253
259
254
func (api * api ) templatesByOrganization (rw http.ResponseWriter , r * http.Request ) {
@@ -284,8 +279,8 @@ func (api *api) templatesByOrganization(rw http.ResponseWriter, r *http.Request)
284
279
})
285
280
return
286
281
}
287
- render . Status ( r , http . StatusOK )
288
- render . JSON (rw , r , convertTemplates (templates , workspaceCounts ))
282
+
283
+ httpapi . Write (rw , http . StatusOK , convertTemplates (templates , workspaceCounts ))
289
284
}
290
285
291
286
func (api * api ) templateByOrganizationAndName (rw http.ResponseWriter , r * http.Request ) {
@@ -325,8 +320,7 @@ func (api *api) templateByOrganizationAndName(rw http.ResponseWriter, r *http.Re
325
320
count = uint32 (workspaceCounts [0 ].Count )
326
321
}
327
322
328
- render .Status (r , http .StatusOK )
329
- render .JSON (rw , r , convertTemplate (template , count ))
323
+ httpapi .Write (rw , http .StatusOK , convertTemplate (template , count ))
330
324
}
331
325
332
326
// convertOrganization consumes the database representation and outputs an API friendly representation.
0 commit comments