orbiter/api/autoscaler-ls.go
Abdulrahman Solanke ad6ccde1bb switch to go mod
2023-05-19 00:58:50 +01:00

30 lines
534 B
Go

package api
import (
"encoding/json"
"net/http"
"github.com/sarkk0x0/orbiter/autoscaler"
)
type AutoscalerResponse struct {
Name string `json:"name"`
}
func AutoscalerList(scalers autoscaler.Autoscalers) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
l := []AutoscalerResponse{}
for n, _ := range scalers {
c := AutoscalerResponse{
Name: n,
}
l = append(l, c)
}
cc := &CollectionResponse{
Data: l,
}
b, _ := json.Marshal(cc)
w.Write(b)
}
}