1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

refactor(api): API overhaul (#392)

This commit is contained in:
Anthony Lapenna 2016-12-18 18:21:29 +13:00 committed by GitHub
parent d9f6124609
commit 0a38bba874
36 changed files with 1275 additions and 869 deletions

View file

@ -0,0 +1,39 @@
package http
import (
"github.com/portainer/portainer"
"github.com/gorilla/mux"
"log"
"net/http"
"os"
)
// SettingsHandler represents an HTTP API handler for managing settings.
type SettingsHandler struct {
*mux.Router
Logger *log.Logger
middleWareService *middleWareService
settings *portainer.Settings
}
// NewSettingsHandler returns a new instance of SettingsHandler.
func NewSettingsHandler(middleWareService *middleWareService) *SettingsHandler {
h := &SettingsHandler{
Router: mux.NewRouter(),
Logger: log.New(os.Stderr, "", log.LstdFlags),
middleWareService: middleWareService,
}
h.HandleFunc("/settings", h.handleGetSettings)
return h
}
// handleGetSettings handles GET requests on /settings
func (handler *SettingsHandler) handleGetSettings(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
handleNotAllowed(w, []string{"GET"})
return
}
encodeJSON(w, handler.settings, handler.Logger)
}