mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
26 lines
549 B
Go
26 lines
549 B
Go
|
package cluster
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
func (c *Cluster) getHandler(handler http.Handler) (http.Handler, error) {
|
||
|
next := c.router()
|
||
|
|
||
|
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||
|
handler.ServeHTTP(rw, req)
|
||
|
next.ServeHTTP(rw, req)
|
||
|
}), nil
|
||
|
}
|
||
|
|
||
|
func (c *Cluster) router() http.Handler {
|
||
|
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||
|
if c.runtime.Handler == nil {
|
||
|
http.Error(rw, "starting", http.StatusServiceUnavailable)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
c.runtime.Handler.ServeHTTP(rw, req)
|
||
|
})
|
||
|
}
|