mirror of https://github.com/docker/docs.git
Experimental web UI
This commit is contained in:
parent
4c5eb22cb2
commit
6d8420898c
|
@ -19,6 +19,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"sort"
|
"sort"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (docker *Docker) CmdHelp(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (docker *Docker) CmdHelp(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
|
@ -36,6 +37,7 @@ func (docker *Docker) CmdHelp(stdin io.ReadCloser, stdout io.Writer, args ...str
|
||||||
{"export", "Extract changes to a container's filesystem into a new layer"},
|
{"export", "Extract changes to a container's filesystem into a new layer"},
|
||||||
{"attach", "Attach to the standard inputs and outputs of a running container"},
|
{"attach", "Attach to the standard inputs and outputs of a running container"},
|
||||||
{"info", "Display system-wide information"},
|
{"info", "Display system-wide information"},
|
||||||
|
{"web", "Generate a web UI"},
|
||||||
} {
|
} {
|
||||||
fmt.Fprintf(stdout, " %-10.10s%s\n", cmd...)
|
fmt.Fprintf(stdout, " %-10.10s%s\n", cmd...)
|
||||||
}
|
}
|
||||||
|
@ -350,6 +352,8 @@ func (docker *Docker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("%s\n", strings.Join(append(append([]string{"docker"}, cmd), args...), " "))
|
log.Printf("%s\n", strings.Join(append(append([]string{"docker"}, cmd), args...), " "))
|
||||||
if cmd == "" {
|
if cmd == "" {
|
||||||
cmd = "help"
|
cmd = "help"
|
||||||
|
} else if cmd == "web" {
|
||||||
|
w.Header().Set("content-type", "text/html")
|
||||||
}
|
}
|
||||||
method := docker.getMethod(cmd)
|
method := docker.getMethod(cmd)
|
||||||
if method == nil {
|
if method == nil {
|
||||||
|
@ -362,6 +366,15 @@ func (docker *Docker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (docker *Docker) CmdWeb(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
|
if file, err := os.Open("dockerweb.html"); err != nil {
|
||||||
|
return err
|
||||||
|
} else if _, err := io.Copy(stdout, file); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (docker *Docker) getMethod(name string) Cmd {
|
func (docker *Docker) getMethod(name string) Cmd {
|
||||||
methodName := "Cmd"+strings.ToUpper(name[:1])+strings.ToLower(name[1:])
|
methodName := "Cmd"+strings.ToUpper(name[:1])+strings.ToLower(name[1:])
|
||||||
method, exists := reflect.TypeOf(docker).MethodByName(methodName)
|
method, exists := reflect.TypeOf(docker).MethodByName(methodName)
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue