mirror of
https://github.com/kopia/kopia.git
synced 2026-01-28 16:23:04 -05:00
29 lines
594 B
Go
29 lines
594 B
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"sort"
|
|
|
|
"github.com/kopia/kopia/internal/serverapi"
|
|
)
|
|
|
|
func (s *Server) handleSourcesList(ctx context.Context, r *http.Request) (interface{}, *apiError) {
|
|
resp := &serverapi.SourcesResponse{
|
|
Sources: []serverapi.SourceStatus{},
|
|
}
|
|
|
|
for _, v := range s.sourceManagers {
|
|
if !sourceMatchesURLFilter(v.src, r.URL.Query()) {
|
|
continue
|
|
}
|
|
resp.Sources = append(resp.Sources, v.Status())
|
|
}
|
|
|
|
sort.Slice(resp.Sources, func(i, j int) bool {
|
|
return resp.Sources[i].Source.String() < resp.Sources[j].Source.String()
|
|
})
|
|
|
|
return resp, nil
|
|
}
|