diff --git a/mail/Makefile b/mail/Makefile index e848bf9..0421f99 100644 --- a/mail/Makefile +++ b/mail/Makefile @@ -1,13 +1,29 @@ -build-and-run: - make install_deps - make build - make run +# Define variables +GO_BUILD_FLAGS = -o bin/main + +# Define targets + +.PHONY: install_deps build run clean install_deps: - go mod download + @echo "Downloading dependencies..." + @go mod download + +build: install_deps + @echo "Building server..." + @go build $(GO_BUILD_FLAGS) cmd/main/main.go + +run: build + @echo "Running mail server" + @./bin/main + +clean: + @echo "Cleaning up...." + @rm -rf bin/main -build: - go build -o bin/main cmd/main/main.go +# Help target +.PHONY: help -run: - go run ./cmd/main \ No newline at end of file +help: + @echo "Available targets:" + @grep -E '^.+:' Makefile diff --git a/mail/bin/main b/mail/bin/main index 2c5335c..fe018d8 100755 Binary files a/mail/bin/main and b/mail/bin/main differ diff --git a/mail/cmd/main/main.go b/mail/cmd/main/main.go index 672407d..e29f587 100644 --- a/mail/cmd/main/main.go +++ b/mail/cmd/main/main.go @@ -13,7 +13,9 @@ import ( ) func main() { - + var ( + ADDR string = ":6969" + ) r := mux.NewRouter() err := godotenv.Load() @@ -22,9 +24,9 @@ func main() { return } - r.HandleFunc("/send-mail", MailRequestHandler).Methods("POST") - fmt.Println("Server live at :6969") - http.ListenAndServe(":6969", r) + r.HandleFunc("/v0/mails", MailRequestHandler).Methods("POST") + fmt.Println("Server live at http://127.0.0.1"+ADDR) + http.ListenAndServe(ADDR, r) } func MailRequestHandler(w http.ResponseWriter, r *http.Request) {