This commit is contained in:
12
main.go
12
main.go
@@ -86,12 +86,14 @@ func (a *App) HandleSave(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
type PoolServer struct {
|
||||
pool GrainPool
|
||||
pod_name string
|
||||
pool GrainPool
|
||||
}
|
||||
|
||||
func NewPoolServer(pool GrainPool) *PoolServer {
|
||||
func NewPoolServer(pool GrainPool, pod_name string) *PoolServer {
|
||||
return &PoolServer{
|
||||
pool: pool,
|
||||
pod_name: pod_name,
|
||||
pool: pool,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +106,7 @@ func (s *PoolServer) HandleGet(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Header().Set("X-Pod-Name", s.pod_name)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write(data)
|
||||
}
|
||||
@@ -121,6 +124,7 @@ func (s *PoolServer) HandleAddSku(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Header().Set("X-Pod-Name", s.pod_name)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write(data)
|
||||
}
|
||||
@@ -186,7 +190,7 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
syncedServer := NewPoolServer(syncedPool)
|
||||
syncedServer := NewPoolServer(syncedPool, name)
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/api/", http.StripPrefix("/api", syncedServer.Serve()))
|
||||
mux.HandleFunc("GET /add/remote/{host}", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user