mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Skeleton of http API
This commit is contained in:
parent
e41fd24542
commit
38e2d00199
3 changed files with 68 additions and 0 deletions
63
api.go
Normal file
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) {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -959,10 +959,12 @@ func NewServer() (*Server, error) {
|
|||
}
|
||||
srv := &Server{
|
||||
runtime: runtime,
|
||||
restEndpoint: NewRestEndpoint(runtime),
|
||||
}
|
||||
return srv, nil
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
runtime *Runtime
|
||||
restEndpoint *RestEndpoint
|
||||
}
|
||||
|
|
|
@ -52,6 +52,9 @@ func daemon() 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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue