Separate API router from server.

Implement basic interfaces to write custom routers that can be plugged
to the server. Remove server coupling with the daemon.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: da982cf5511814b6897244ecaa9c016f8800340a
Component: engine
This commit is contained in:
David Calavera
2015-09-23 19:42:08 -04:00
parent e5db2c0e2f
commit 1fb74bb17c
32 changed files with 809 additions and 591 deletions

View File

@ -6,8 +6,6 @@ import (
"errors"
"net"
"net/http"
"github.com/docker/docker/daemon"
)
// NewServer sets up the required Server and does protocol specific checking.
@ -32,7 +30,7 @@ func (s *Server) newServer(proto, addr string) ([]serverCloser, error) {
res = append(res, &HTTPServer{
&http.Server{
Addr: addr,
Handler: s.router,
Handler: s.CreateMux(),
},
l,
})
@ -41,18 +39,6 @@ func (s *Server) newServer(proto, addr string) ([]serverCloser, error) {
}
// AcceptConnections allows router to start listening for the incoming requests.
func (s *Server) AcceptConnections(d *daemon.Daemon) {
s.daemon = d
s.registerSubRouter()
// close the lock so the listeners start accepting connections
select {
case <-s.start:
default:
close(s.start)
}
}
func allocateDaemonPort(addr string) error {
return nil
}