Skip to content

Commit

Permalink
Merge branch '1-run-gin-as-debug' of https://github.com/mohitrajane/c…
Browse files Browse the repository at this point in the history
…ovid19-kerala-api into mohitrajane-1-run-gin-as-debug
  • Loading branch information
yedhink committed Apr 10, 2020
2 parents 3cba362 + fa505ff commit 310dd89
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ ifneq ($(PIPENV_ACTIVE), 1)
endif
go mod vendor
go build -mod=vendor -v -o bin/covid19keralaapi cmd/covid19keralaapi/main.go
PORT=5000 bin/covid19keralaapi
PORT=5000 GIN_MODE=release bin/covid19keralaapi

run:
# runs on port 8000 by default
go run -mod=vendor cmd/covid19keralaapi/main.go
# runs on port 8080 by default
go run -mod=vendor cmd/covid19keralaapi/main.go
10 changes: 4 additions & 6 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package server
import (
"github.com/gin-gonic/gin"
"github.com/thinkerou/favicon"
. "github.com/yedhink/covid19-kerala-api/internal/model"
. "github.com/yedhink/covid19-kerala-api/internal/controller"
. "github.com/yedhink/covid19-kerala-api/internal/logger"
. "github.com/yedhink/covid19-kerala-api/internal/model"
. "github.com/yedhink/covid19-kerala-api/internal/storage"
)

type Server struct {
Port string
Port string
JsonData DataSet
}

Expand All @@ -21,16 +21,14 @@ func (server *Server) Start(st *Storage) {
return
}

// run in Release mode by default
gin.SetMode(gin.ReleaseMode)
router := gin.New()
router.Use(gin.Logger(),gin.Recovery())
router.Use(gin.Logger(), gin.Recovery())
router.Use(favicon.New("web/assets/favicon.ico"))
router.LoadHTMLFiles("web/index.html")
router.GET("/", server.Root())
router.GET("/api", server.Api())
router.GET("/api/location", server.Location(st))
router.GET("/api/timeline", server.TimeLine())
router.NoRoute(server.NoRouteErr())
router.Run(server.Port) // listen and serve on 0.0.0.0:8080 by default
router.Run() // listen and serve on 0.0.0.0:8080 by default
}
9 changes: 7 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,16 @@ The python script is invoked from within the gin-server. Therefore activate the
```bash
pipenv shell
```
Then run the server(note that the executable will be stored in bin/):-
Then run the server(note that the executable will be stored in bin/):-
To run in production mode
```bash
make build
```
Once everything is setup, essentially running `make build` from project root can restart the server everytime.
To run in development mode (i.e. gin server will be in development mode)
```bash
make run
```
Once everything is setup, essentially running `make build` or `make run` (as per requirement) from project root can restart the server everytime.

---

Expand Down

0 comments on commit 310dd89

Please sign in to comment.