24 lines
593 B
Go
24 lines
593 B
Go
package api
|
|
|
|
import (
|
|
"linkport/internal/model"
|
|
"linkport/internal/store"
|
|
"net/http"
|
|
)
|
|
|
|
func requestScope(r *http.Request) model.ResourceScope {
|
|
return model.ResourceScope{Project: r.URL.Query().Get("project"), Environment: r.URL.Query().Get("environment")}
|
|
}
|
|
|
|
func (s *Server) scopeIndex(w http.ResponseWriter, r *http.Request) (store.ScopeIndex, bool) {
|
|
if requestScope(r) == (model.ResourceScope{}) {
|
|
return nil, true
|
|
}
|
|
index, err := s.store.ResourceScopes(r.Context())
|
|
if err != nil {
|
|
fail(w, 500, "cannot load resource ownership")
|
|
return nil, false
|
|
}
|
|
return index, true
|
|
}
|