Skip to content

Commit c0f1c4f

Browse files
committed
feat: added versioning to log, some cleanup
1 parent 077a37e commit c0f1c4f

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

internal/api/routes.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@ import (
44
"net/http"
55

66
"github.com/go-chi/chi/v5"
7+
"github.com/syntaxsdev/mercury/internal/handlers"
78
"github.com/syntaxsdev/mercury/internal/services"
9+
version "github.com/syntaxsdev/mercury/shared"
810
)
911

1012
func InitRoutes(factory *services.Factory) http.Handler {
1113
r := chi.NewRouter()
1214

15+
// Base endpoint / healthy status
16+
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
17+
handlers.WriteHttp(w, 200, "Mercury is up and running.", map[string]interface{}{
18+
"status": "healthy",
19+
"version": version.Version,
20+
})
21+
})
22+
1323
r.Route("/strategy", func(r chi.Router) {
1424
StrategyRoutes(r, factory)
1525
})

internal/handlers/logging.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func GetLog(w http.ResponseWriter, r *http.Request, f *services.Factory, n strin
3333
WriteHttp(w, http.StatusOK, "Successfully fetched all logs", logs)
3434
}
3535

36-
// Create a new log
36+
// Creates a new log
3737
func NewLog(w http.ResponseWriter, r *http.Request, f *services.Factory) {
3838
var newLog models.Log
3939
if err := json.NewDecoder(r.Body).Decode(&newLog); err != nil {

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func main() {
7171
// Start Routes
7272
router := api.InitRoutes(&factory)
7373

74-
log.Printf("INFO: Starting Server... Listening on http://localhost:%s\n", mercuryPort)
74+
log.Printf("INFO: Starting Server... \nListening on http://localhost:%s\n", mercuryPort)
7575
if err := http.ListenAndServe(fmt.Sprintf(":%s", mercuryPort), router); err != nil {
7676
log.Fatalf("Serve failed to start: %v", err)
7777
}

shared/version.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package version
2+
3+
var Version string = "v1.0.1"

0 commit comments

Comments
 (0)