Skip to content

Commit

Permalink
feat: added env param PORT
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay200669 committed Apr 26, 2024
1 parent ac7ed3c commit fc09457
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ curl -X POST http://localhost:8989/calculate \
### Or
3. Use integration test:
```bash
go test -v
go test -v ./...
```
output should be:
```txt
Expand Down
10 changes: 9 additions & 1 deletion cmd/go-ks/main.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
package main

import (
"fmt"
"log"
"net/http"
"os"

"github.com/Nikolay200669/go-ks/internal/app/application"
iface "github.com/Nikolay200669/go-ks/internal/app/interfaces/http"
)

func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8989"
}
addr := fmt.Sprintf(":%s", port)

// Initialize the CalculateService
calculateService := &application.CalculateService{}

// Configure the router
router := iface.SetupRouter(calculateService)

// Run the server
log.Fatal(http.ListenAndServe(":8989", router))
log.Fatal(http.ListenAndServe(addr, router))
}

0 comments on commit fc09457

Please sign in to comment.