Skip to content

Commit

Permalink
feat: added versioning to log, some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
syntaxsdev committed Jan 17, 2025
1 parent 077a37e commit c0f1c4f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
10 changes: 10 additions & 0 deletions internal/api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@ import (
"net/http"

"github.com/go-chi/chi/v5"
"github.com/syntaxsdev/mercury/internal/handlers"
"github.com/syntaxsdev/mercury/internal/services"
version "github.com/syntaxsdev/mercury/shared"
)

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

// Base endpoint / healthy status
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
handlers.WriteHttp(w, 200, "Mercury is up and running.", map[string]interface{}{
"status": "healthy",
"version": version.Version,
})
})

r.Route("/strategy", func(r chi.Router) {
StrategyRoutes(r, factory)
})
Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func GetLog(w http.ResponseWriter, r *http.Request, f *services.Factory, n strin
WriteHttp(w, http.StatusOK, "Successfully fetched all logs", logs)
}

// Create a new log
// Creates a new log
func NewLog(w http.ResponseWriter, r *http.Request, f *services.Factory) {
var newLog models.Log
if err := json.NewDecoder(r.Body).Decode(&newLog); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func main() {
// Start Routes
router := api.InitRoutes(&factory)

log.Printf("INFO: Starting Server... Listening on http://localhost:%s\n", mercuryPort)
log.Printf("INFO: Starting Server... \nListening on http://localhost:%s\n", mercuryPort)
if err := http.ListenAndServe(fmt.Sprintf(":%s", mercuryPort), router); err != nil {
log.Fatalf("Serve failed to start: %v", err)
}
Expand Down
3 changes: 3 additions & 0 deletions shared/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package version

var Version string = "v1.0.1"

0 comments on commit c0f1c4f

Please sign in to comment.