Skip to content

Commit

Permalink
chore:fixes mail Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
zakhaev26 committed Feb 21, 2024
1 parent 215b3fd commit bca18c7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
34 changes: 25 additions & 9 deletions mail/Makefile
Original file line number Diff line number Diff line change
@@ -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
help:
@echo "Available targets:"
@grep -E '^.+:' Makefile
Binary file modified mail/bin/main
Binary file not shown.
10 changes: 6 additions & 4 deletions mail/cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (
)

func main() {

var (
ADDR string = ":6969"
)
r := mux.NewRouter()
err := godotenv.Load()

Expand All @@ -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) {
Expand Down

0 comments on commit bca18c7

Please sign in to comment.