Automatic API generation by adopting go-restful

This commit is contained in:
Brian Grant
2014-11-11 07:11:45 +00:00
parent dd29cd8353
commit 7583e1a643
18 changed files with 408 additions and 142 deletions

View File

@@ -19,16 +19,19 @@ package apiserver
import (
"fmt"
"net/http"
"github.com/emicklei/go-restful"
)
// handleIndex is the root index page for Kubernetes.
func handleIndex(w http.ResponseWriter, req *http.Request) {
if req.URL.Path != "/" && req.URL.Path != "/index.html" {
notFound(w, req)
func handleIndex(req *restful.Request, resp *restful.Response) {
// TODO: use restful's Request/Response methods
if req.Request.URL.Path != "/" && req.Request.URL.Path != "/index.html" {
notFound(resp.ResponseWriter, req.Request)
return
}
w.WriteHeader(http.StatusOK)
// TODO: serve this out of a file?
resp.ResponseWriter.WriteHeader(http.StatusOK)
// TODO: serve this out of a file
data := "<html><body>Welcome to Kubernetes</body></html>"
fmt.Fprint(w, data)
fmt.Fprint(resp.ResponseWriter, data)
}