Merge pull request #8 from fkautz/pr_out_setting_up_initial_cli_options_and_http_handlers
Setting up initial cli options and http handlersmaster
commit
428f012830
@ -0,0 +1,15 @@ |
||||
package minio |
||||
|
||||
import ( |
||||
"fmt" |
||||
"github.com/gorilla/mux" |
||||
"net/http" |
||||
) |
||||
|
||||
func GatewayHandler(w http.ResponseWriter, req *http.Request) { |
||||
fmt.Fprintf(w, "Gateway") |
||||
} |
||||
|
||||
func RegisterGatewayHandlers(router *mux.Router) { |
||||
router.HandleFunc("/gateway/rpc", GatewayHandler) |
||||
} |
@ -0,0 +1,27 @@ |
||||
package minio |
||||
|
||||
import ( |
||||
"io/ioutil" |
||||
"log" |
||||
"net/http" |
||||
"net/http/httptest" |
||||
"testing" |
||||
) |
||||
|
||||
func TestPrintsGateway(t *testing.T) { |
||||
server := httptest.NewServer(http.HandlerFunc(GatewayHandler)) |
||||
defer server.Close() |
||||
res, err := http.Get(server.URL) |
||||
if err != nil { |
||||
log.Fatal(err) |
||||
} |
||||
body, err := ioutil.ReadAll(res.Body) |
||||
res.Body.Close() |
||||
if err != nil { |
||||
log.Fatal(err) |
||||
} |
||||
bodyString := string(body) |
||||
if bodyString != "Gateway" { |
||||
log.Fatal("Expected 'Gateway', Received '" + bodyString + "'") |
||||
} |
||||
} |
@ -1,21 +0,0 @@ |
||||
package minio |
||||
|
||||
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) |
||||
} |
@ -0,0 +1,15 @@ |
||||
package minio |
||||
|
||||
import ( |
||||
"fmt" |
||||
"github.com/gorilla/mux" |
||||
"net/http" |
||||
) |
||||
|
||||
func RegisterStorageHandlers(router *mux.Router) { |
||||
router.HandleFunc("/storage/rpc", StorageHandler) |
||||
} |
||||
|
||||
func StorageHandler(w http.ResponseWriter, req *http.Request) { |
||||
fmt.Fprintf(w, "Storage") |
||||
} |
@ -0,0 +1,27 @@ |
||||
package minio |
||||
|
||||
import ( |
||||
"io/ioutil" |
||||
"log" |
||||
"net/http" |
||||
"net/http/httptest" |
||||
"testing" |
||||
) |
||||
|
||||
func TestPrintsStorage(t *testing.T) { |
||||
server := httptest.NewServer(http.HandlerFunc(StorageHandler)) |
||||
defer server.Close() |
||||
res, err := http.Get(server.URL) |
||||
if err != nil { |
||||
log.Fatal(err) |
||||
} |
||||
body, err := ioutil.ReadAll(res.Body) |
||||
res.Body.Close() |
||||
if err != nil { |
||||
log.Fatal(err) |
||||
} |
||||
bodyString := string(body) |
||||
if bodyString != "Storage" { |
||||
log.Fatal("Expected 'Storage', Received '" + bodyString + "'") |
||||
} |
||||
} |
Loading…
Reference in new issue