Update to new goprogram version
This commit is contained in:
parent
7bd9570bc0
commit
873fdcd5c2
106 changed files with 478 additions and 825 deletions
|
|
@ -15,7 +15,7 @@ import (
|
|||
// API implements an API to list all instances
|
||||
type API struct {
|
||||
component.Base
|
||||
Dependencies struct {
|
||||
dependencies struct {
|
||||
ListInstances *ListInstances
|
||||
Auth *auth.Auth
|
||||
}
|
||||
|
|
@ -42,15 +42,15 @@ type APISystem struct {
|
|||
func (a *API) HandleRoute(ctx context.Context, path string) (http.Handler, error) {
|
||||
return &api.Handler[[]APISystem]{
|
||||
Config: a.Config,
|
||||
Auth: a.Dependencies.Auth,
|
||||
Auth: a.dependencies.Auth,
|
||||
|
||||
Methods: []string{"GET"},
|
||||
Scope: scopes.ScopeInstanceDirectory,
|
||||
|
||||
Handler: func(s string, r *http.Request) ([]APISystem, error) {
|
||||
var statuses []status.WissKI
|
||||
if a.Dependencies.ListInstances.ShouldShowList(r) {
|
||||
statuses = a.Dependencies.ListInstances.infos.Get(nil)
|
||||
if a.dependencies.ListInstances.ShouldShowList(r) {
|
||||
statuses = a.dependencies.ListInstances.infos.Get(nil)
|
||||
}
|
||||
|
||||
if len(statuses) == 0 {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ type ListInstances struct {
|
|||
names lazy.Lazy[map[string]struct{}] // instance names
|
||||
infos lazy.Lazy[[]status.WissKI] // list of home instances (updated via cron)
|
||||
|
||||
Dependencies struct {
|
||||
dependencies struct {
|
||||
Auth *auth.Auth
|
||||
Instances *instances.Instances
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ func (li *ListInstances) ShouldShowList(r *http.Request) bool {
|
|||
return allowPrivate
|
||||
}
|
||||
|
||||
_, user, _ := li.Dependencies.Auth.SessionOf(r)
|
||||
_, user, _ := li.dependencies.Auth.SessionOf(r)
|
||||
if user == nil {
|
||||
return allowPublic
|
||||
} else {
|
||||
|
|
@ -82,7 +82,7 @@ func (li *ListInstances) Cron(ctx context.Context) (err error) {
|
|||
|
||||
// getNames returns the names of the given instances
|
||||
func (li *ListInstances) getNames(ctx context.Context) (map[string]struct{}, error) {
|
||||
wissKIs, err := li.Dependencies.Instances.All(ctx)
|
||||
wissKIs, err := li.dependencies.Instances.All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ func (li *ListInstances) getNames(ctx context.Context) (map[string]struct{}, err
|
|||
// getInfos returns the names of the given instances
|
||||
func (li *ListInstances) getInfos(ctx context.Context) ([]status.WissKI, error) {
|
||||
// find all the WissKIs
|
||||
wissKIs, err := li.Dependencies.Instances.All(ctx)
|
||||
wissKIs, err := li.dependencies.Instances.All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue