MCPcopy Create free account
hub / github.com/linuxkit/linuxkit / serveCmd

Function serveCmd

src/cmd/linuxkit/serve.go:17–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15}
16
17func serveCmd() *cobra.Command {
18 var (
19 port string
20 dir string
21 )
22 cmd := &cobra.Command{
23 Use: "serve",
24 Short: "serve a directory over http",
25 Long: `Serve a directory over http.`,
26 RunE: func(cmd *cobra.Command, args []string) error {
27 http.Handle("/", http.FileServer(http.Dir(dir)))
28 log.Fatal(http.ListenAndServe(port, logRequest(http.DefaultServeMux)))
29
30 return nil
31 },
32 }
33
34 cmd.Flags().StringVar(&port, "port", ":8080", "Local port to serve on")
35 cmd.Flags().StringVar(&dir, "directory", ".", "Directory to serve")
36
37 return cmd
38}

Callers 1

newCmdFunction · 0.85

Calls 1

logRequestFunction · 0.85

Tested by

no test coverage detected