-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated posgres connection logic, added a folder for handlers, improv…
…ed docker-compose to restart app container unless stopped. Reduced COPY steps in dockerfile
- Loading branch information
1 parent
1061367
commit 115789f
Showing
7 changed files
with
67 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
.PHONY: build run | ||
.PHONY: build up run kill | ||
|
||
build: | ||
podman-compose build | ||
@echo "Building Docker image..." | ||
podman build . | ||
|
||
run: build | ||
podman-compose up | ||
up: | ||
@echo "Running container..." | ||
podman-compose up | ||
|
||
run: build up | ||
|
||
kill: | ||
@echo "Stopping containers..." | ||
podman-compose down | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package handlers | ||
|
||
import ( | ||
"fmt" | ||
"myapp/src/utils" | ||
"net/http" | ||
|
||
"github.com/rs/zerolog" | ||
) | ||
|
||
// HomeHandler handles the home route | ||
func HomeHandler(app *utils.App, logger zerolog.Logger) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
// Extract user ID from JWT | ||
userID, err := utils.ExtractClaim(r.Context(), "user_id") | ||
if err != nil { | ||
logger.Error().Err(err).Msg("Failed to extract user_id from token") | ||
http.Error(w, "Unauthorized", http.StatusUnauthorized) | ||
return | ||
} | ||
|
||
// Log and respond with a message | ||
logger.Info().Str("user_id", userID).Msg("Home page accessed") | ||
response := fmt.Sprintf("Welcome to MyApp, %s!", userID) | ||
w.Write([]byte(response)) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters