Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
fix: image directory path
Browse files Browse the repository at this point in the history
  • Loading branch information
Frecherenkel60 committed Jul 7, 2023
1 parent 37a054b commit da1856d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ module expense-management-images

go 1.20

require github.com/gin-gonic/gin v1.9.1
require (
github.com/gin-gonic/gin v1.9.1
github.com/joho/godotenv v1.5.1
)

require (
github.com/bytedance/sonic v1.9.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
Expand Down
9 changes: 9 additions & 0 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ import (
"os"
"os/signal"
"time"

"github.com/joho/godotenv"
)

func main() {
log.SetFlags(log.Lshortfile | log.LstdFlags)
// LOAD ENVIRONMENT VARIABLES
log.Println("Loading environment variables...")
err := godotenv.Load()
if err != nil {
log.Printf("Error loading .env file:: %v", err)
}
log.Println("Environment variables loaded successfully")

// CREATE ROUTER
log.Println("Creating router...")
Expand Down
5 changes: 4 additions & 1 deletion src/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"expense-management-images/src/handlers"
"expense-management-images/src/middlewares"
"net/http"
"os"

"github.com/gin-gonic/gin"
)
Expand Down Expand Up @@ -33,8 +34,10 @@ func createRouter() *gin.Engine {
ImageController: &controllers.ImageController{},
}

imageDirectory := os.Getenv("IMAGE_DIRECTORY")

router.Handle(http.MethodGet, "/lifecheck", handlers.LifeCheckHandler())
router.StaticFS("/images", gin.Dir("/app/images", true))
router.StaticFS("/images", gin.Dir(imageDirectory, true))
apiv1.Handle(http.MethodPost, "/images", handlers.UploadImageHandler(controller.ImageController))

return router
Expand Down

0 comments on commit da1856d

Please sign in to comment.