Code imported from @CesarGallego private repo

This commit is contained in:
Roberto Abdelkader Martínez Pérez
2019-10-02 15:49:16 +02:00
parent e146ec6647
commit 3602dc71f2
10 changed files with 328 additions and 22 deletions
+15 -22
View File
@@ -2,31 +2,24 @@ package main
import (
"fmt"
b "github.com/BBVA/kapow/pkg/banner"
"net/http"
"os"
"github.com/spf13/cobra"
"github.com/BBVA/kapow/command"
)
func main() {
ban := b.Banner("0.1.0")
fmt.Println(ban)
var kapowCmd = &cobra.Command{Use: "kapow [action]"}
go func() {
http.ListenAndServe(":8080", &userServerHandler{})
}()
http.ListenAndServe(":8081", &controlAPIHandler{})
kapowCmd.AddCommand(command.ServerCmd)
kapowCmd.AddCommand(command.GetCmd)
kapowCmd.AddCommand(command.SetCmd)
kapowCmd.AddCommand(command.RouteCmd)
}
type userServerHandler struct {
}
func (m *userServerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotImplemented)
}
type controlAPIHandler struct {
}
func (m *controlAPIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotImplemented)
err := kapowCmd.Execute()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}