1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/api/server/router/router.go
David Calavera da982cf551 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>
2015-09-29 19:43:03 -04:00

25 lines
684 B
Go

package router
import (
"net/http"
"github.com/docker/docker/api/server/httputils"
"github.com/gorilla/mux"
)
// VersionMatcher defines a variable matcher to be parsed by the router
// when a request is about to be served.
const VersionMatcher = "/v{version:[0-9.]+}"
// Router defines an interface to specify a group of routes to add the the docker server.
type Router interface {
Routes() []Route
}
// Route defines an individual API route in the docker server.
type Route interface {
// Register adds the handler route to the docker mux.
Register(*mux.Router, http.Handler)
// Handler returns the raw function to create the http handler.
Handler() httputils.APIFunc
}