README.md 2.35 KiB
Newer Older
Somnath Ghorpade's avatar
Somnath Ghorpade committed
Golang Gin web framework template project
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
## Steps to run Go Template project on local
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
- Server is a golang gin framework developed at Go v1.20.08+
- Before running update following files according to environment:
  - Update db related config in - `database.json`
  - Server requires mongodb database (version 4.4.13)
- To run:
  - `go mod tidy`
  - `go run main.go`
- To Build:
  - To log errors from commandline, prepare build in `Production` mode. 
  - Set `IS_PRODUCTION = true` in **main.go** file for production build. And create build with below command. 
     ```go
     go build -tags prod
     ```
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
## Test the gotemplate project
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
- `GoTemplate.postman_collection.json` postman collection.
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
## Pprof usage
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
- To check pprof uncomment pprof call from main file.
- Use profiling for your server see the documentation  <https://pkg.go.dev/net/http/pprof>
- also after starting pprof server use this command to check profiling
    `go tool pprof http://localhost:YOUR_PPROF_PORT/debug/pprof/heap`
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
## JWT Usage
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
- To use jwt authentication and its variables uncomment decodeToken method to access all token variables.
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
## MySQL Connection
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
- To get Mysql DB connection using provided json file just uncomment the  `InitMysqlDBConnectionUsingJson` method from main file.
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
## MSSQLServer Connection
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
- To get sql server connection using provided json file just uncomment the  `InitSQLServerConnectionUsingJson` method from main file.
- There are two ways we can get connection object.
  1. first is using GetSQLServerDAO() method:
     `GetSQLServerDAO()` returns the default sql server connection object.
  2. second is using GetSQLServerDAOWithHost("hostName") method:
     `GetSQLServerDAOWithHost("hostName")` returns the sql server connection object of specified HostName.
     This method is used when we need to get connection object, other than default database.
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
 ## Immudb Operations
 - To get immudb server connection using provided json file just uncomment the       `InitImmuDBConnectionUsingJson` method from main file.
 -  To get the connection object GetImmuDAOWithHost(coreimmudb.DefaultHostName) method is used.
   `GetImmuDAOWithHost(coreimmudb.DefaultHostName)` returns the immudb server connection object of    specified HostName. This method is used when we need to get connection object, other than default database.
Vijay Kumar Chauhan's avatar
Vijay Kumar Chauhan committed

Somnath Ghorpade's avatar
Somnath Ghorpade committed
 Note: All Immudb operations' result is in Base64 format.