Skip to content

go-flexible/flexhttp

Repository files navigation

flexhttp

Go Reference Go

A flex compatible http server.

// Create some router and endpoints...
router := http.NewServeMux()
router.HandleFunc("/", func(rw http.ResponseWriter, r *http.Request) {
        fmt.Fprint(rw, "Hello, world!\n")
})

// Create a standard http server.
srv := &http.Server{
        Addr:              ":8080",
        Handler:           router,
        ReadTimeout:       5 * time.Second, 
        ReadHeaderTimeout: time.Second,
        // Missing timeouts will be set to a sane default.
}

// Run it, or better yet, let `flex` run it!
flexhttp.New(srv).Run(context.Background())