mirror of
https://github.com/1f349/site-hosting.git
synced 2025-04-12 22:56:02 +01:00
Output GET /sites as an array of domain objects
This commit is contained in:
parent
8d8d54df0d
commit
ce4b78cc1d
15
api/api.go
15
api/api.go
@ -67,8 +67,21 @@ func New(upload *upload.Handler, keyStore *mjwt.KeyStore, db apiDB) *httprouter.
|
||||
domains[i.Domain] = append(domains[i.Domain], i)
|
||||
}
|
||||
|
||||
type domainObject struct {
|
||||
Domain string `json:"domain"`
|
||||
Branches []database.Branch `json:"branches"`
|
||||
}
|
||||
|
||||
domainObjs := make([]domainObject, 0, len(domains))
|
||||
for k, v := range domains {
|
||||
domainObjs = append(domainObjs, domainObject{
|
||||
Domain: k,
|
||||
Branches: v,
|
||||
})
|
||||
}
|
||||
|
||||
rw.WriteHeader(http.StatusOK)
|
||||
_ = json.NewEncoder(rw).Encode(domains)
|
||||
_ = json.NewEncoder(rw).Encode(domainObjs)
|
||||
}))
|
||||
|
||||
// Site creation endpoint
|
||||
|
Loading…
x
Reference in New Issue
Block a user