added cache

This commit is contained in:
2019-11-01 14:25:11 +01:00
parent 75c2b684b7
commit b425e6ff28
5 changed files with 235 additions and 31 deletions

View File

@ -16,12 +16,10 @@ limitations under the License.
package cmd
import (
"fmt"
"github.com/dalu/chromedom/server"
"github.com/spf13/cobra"
"net"
"net/http"
"os"
"time"
)
// serveCmd represents the serve command
@ -32,13 +30,15 @@ var serveCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
binary := cmd.Flag("binary").Value.String()
s := http.DefaultServeMux
h := server.NewHandler(binary)
h := server.NewHandler(binary, 30*time.Minute)
s.Handle("/", h)
return http.ListenAndServe(":9292", s)
// return RunUnix("/tmp/chromedom.sock", s)
},
}
/*
func RunUnix(file string, engine *http.ServeMux) (err error) {
fmt.Printf("Listening and serving HTTP on unix:/%s", file)
os.Remove(file)
@ -51,6 +51,7 @@ func RunUnix(file string, engine *http.ServeMux) (err error) {
err = http.Serve(listener, engine)
return
}
*/
func init() {
rootCmd.AddCommand(serveCmd)