Update api-server to use env vars for connecting with grpc keygen server
This commit is contained in:
parent
7274f4950a
commit
038d9f3baf
3 changed files with 12 additions and 5 deletions
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
port, err := strconv.Atoi(env.GetEnv("API_PORT", "8081"))
|
||||
port, err := strconv.Atoi(env.GetEnv("API_PORT", "8080"))
|
||||
if err != nil {
|
||||
log.Fatalf("error listening port: %v, err: %v", port, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
pb "fastbin/api/keygen"
|
||||
|
||||
"fastbin/internal/pkg/env"
|
||||
paste "fastbin/internal/pkg/paste"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
@ -106,7 +107,7 @@ func (as *APIServer) write(gc *gin.Context) {
|
|||
}
|
||||
|
||||
func (as *APIServer) try_write(data string) (string, error) {
|
||||
grpcServerURL := "localhost:8081"
|
||||
grpcServerURL := env.GetEnv("KEYGEN_HOST", "localhost") + ":" + env.GetEnv("KEYGEN_PORT", "8080")
|
||||
conn, err := grpc.NewClient(grpcServerURL, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
|
|||
12
syntax.env
12
syntax.env
|
|
@ -1,7 +1,13 @@
|
|||
WEB_PORT=8082
|
||||
|
||||
API_PORT=8080
|
||||
WEB_PORT=8081
|
||||
DB_HOST=localhost
|
||||
API_HOST=localhost
|
||||
|
||||
KEYGEN_PORT=8081
|
||||
KEYGEN_HOST=localhost
|
||||
|
||||
DB_PORT=5432
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=fastbin
|
||||
DB_USERNAME=username
|
||||
DB_PASSWORD=password
|
||||
DB_PASSWORD=password
|
||||
|
|
|
|||
Loading…
Reference in a new issue