This commit is contained in:
Solomon Hykes 2013-04-10 19:48:21 -07:00 коммит произвёл Victor Vieux
Родитель 2a47df0202
Коммит a11b31399b
3 изменённых файлов: 68 добавлений и 0 удалений

63
api.go Normal file
Просмотреть файл

@ -0,0 +1,63 @@
package docker
import (
"github.com/gorilla/mux"
"net/http"
_"encoding/json"
)
type RestEndpoint struct {
*mux.Router
runtime *Runtime
}
func NewRestEndpoint(runtime *Runtime) *RestEndpoint {
endpoint := &RestEndpoint{
Router: mux.NewRouter(),
runtime: runtime,
}
endpoint.Path("/images").Methods("GET").HandlerFunc(endpoint.GetImages)
endpoint.Path("/images").Methods("POST").HandlerFunc(endpoint.PostImages)
endpoint.Path("/images/{id}").Methods("GET").HandlerFunc(endpoint.GetImage)
endpoint.Path("/images/{id}").Methods("DELETE").HandlerFunc(endpoint.DeleteImage)
endpoint.Path("/containers").Methods("GET").HandlerFunc(endpoint.GetContainers)
endpoint.Path("/containers").Methods("POST").HandlerFunc(endpoint.PostContainers)
endpoint.Path("/containers/{id}").Methods("GET").HandlerFunc(endpoint.GetContainer)
endpoint.Path("/containers/{id}").Methods("DELETE").HandlerFunc(endpoint.DeleteContainer)
return endpoint
}
func (ep *RestEndpoint) GetImages(w http.ResponseWriter, r *http.Response) {
}
func (ep *RestEndpoint) PostImages(w http.ResponseWriter, r *http.Response) {
}
func (ep *RestEndpoint) GetImage(w http.ResponseWriter, r *http.Response) {
}
func (ep *RestEndpoint) DeleteImage(w http.ResponseWriter, r *http.Response) {
}
func (ep *RestEndpoint) GetContainers(w http.ResponseWriter, r *http.Response) {
}
func (ep *RestEndpoint) PostContainers(w http.ResponseWriter, r *http.Response) {
}
func (ep *RestEndpoint) GetContainer(w http.ResponseWriter, r *http.Response) {
}
func (ep *RestEndpoint) DeleteContainer(w http.ResponseWriter, r *http.Response) {
}

Просмотреть файл

@ -986,10 +986,12 @@ func NewServer() (*Server, error) {
}
srv := &Server{
runtime: runtime,
restEndpoint: NewRestEndpoint(runtime),
}
return srv, nil
}
type Server struct {
runtime *Runtime
restEndpoint *RestEndpoint
}

Просмотреть файл

@ -99,6 +99,9 @@ func daemon(pidfile string) error {
if err != nil {
return err
}
if err := http.ListenAndServe("0.0.0.0:4243", service.restEndpoint); err != nil {
return err
}
return rcli.ListenAndServe("tcp", "127.0.0.1:4242", service)
}