Quellcode durchsuchen

modif makefile default goal

Christian Marian - Work Dell vor 1 Monat
Ursprung
Commit
c394503568
3 geänderte Dateien mit 13 neuen und 3 gelöschten Zeilen
  1. 2 0
      Makefile
  2. 3 3
      cmds/webservice/main.go
  3. 8 0
      lib/server/srv.go

+ 2 - 0
Makefile

@@ -1,3 +1,5 @@
+.DEFAULT_GOAL := help
+
 commit:
 	
 	@read -p "Enter commit message:" msg; \

+ 3 - 3
cmds/webservice/main.go

@@ -14,14 +14,14 @@ func main() {
 	case 3:
 		if args[1] == "--run" {
 			serve(args[2])
+			os.Exit(0)
 		}
 		fmt.Printf("Comanda %s nu este configurata\n", args[1])
-		fmt.Printf("Argumente rulare: %v\n", args)
+
 	default:
 		fmt.Println("Aplicatia necesita minim 2 parametri")
-		fmt.Printf("Argumente rulare: %v\n", args)
 	}
-
+	fmt.Printf("Argumente rulare: %v\n", args)
 }
 
 func serve(filename string) {

+ 8 - 0
lib/server/srv.go

@@ -18,9 +18,17 @@ func NewServer(filename string) *Server {
 
 }
 
+func Ceva(s *Server) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		//s.Err = fmt.Errorf("bla")
+		s_json := inout.ObjToJson(s)
+		w.Write([]byte(s_json))
+	}
+}
 func (s *Server) Run() {
 	// adding endpoints to the server
 	http.HandleFunc("/", Wildcard)
+	http.Handle("/ceva", Ceva(s))
 
 	//running server
 	fmt.Printf("Server running at http://%s:%s/\n", s.Host, s.Port)