From e58cada88cfda00959308c7e133e8a26129b7205 Mon Sep 17 00:00:00 2001 From: "Frederick F. Kautz IV" Date: Sat, 1 Nov 2014 21:05:40 -0700 Subject: [PATCH] miniosd is now an http server, responds with hello world at root. --- miniosd/main.go | 7 +++++-- server.go | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 server.go diff --git a/miniosd/main.go b/miniosd/main.go index d8fa92921..8391b5d41 100644 --- a/miniosd/main.go +++ b/miniosd/main.go @@ -1,7 +1,10 @@ package main -import "fmt" +import ( + "github.com/minios/minios" +) func main() { - fmt.Println("hello") + server := minios.Server{} + server.Start() } diff --git a/server.go b/server.go new file mode 100644 index 000000000..6c5e021be --- /dev/null +++ b/server.go @@ -0,0 +1,21 @@ +package minios + +import ( + "fmt" + "github.com/gorilla/mux" + "net/http" +) + +type Server struct { +} + +func (server *Server) Start() error { + r := mux.NewRouter() + r.HandleFunc("/", HelloHandler) + fmt.Println("Running http server on port 8080") + return http.ListenAndServe(":8080", r) +} + +func HelloHandler(w http.ResponseWriter, req *http.Request) { + fmt.Fprintf(w, "Host: "+req.Host) +}