1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 04:15:28 +02:00

refactor(api): create a new structure for the Go api (#94)

* refactor(api): create a new structure for the Go api

* refactor(api): update the way keyFile parameter is managed
This commit is contained in:
Anthony Lapenna 2016-08-01 13:40:12 +12:00 committed by GitHub
parent 06c2635e82
commit b0ebbdf68c
9 changed files with 325 additions and 246 deletions

25
api/config.go Normal file
View file

@ -0,0 +1,25 @@
package main
import (
"encoding/json"
"net/http"
)
// Config defines the configuration available under the /config endpoint
type Config struct {
Swarm bool `json:"swarm"`
HiddenLabels pairList `json:"hiddenLabels"`
}
// newConfig creates a new Config from command flags
func newConfig(swarm bool, labels pairList) Config {
return Config{
Swarm: swarm,
HiddenLabels: labels,
}
}
// configurationHandler defines a handler function used to encode the configuration in JSON
func configurationHandler(w http.ResponseWriter, r *http.Request, c Config) {
json.NewEncoder(w).Encode(c)
}