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() {
|
func main() {
|
||||||
port, err := strconv.Atoi(env.GetEnv("API_PORT", "8081"))
|
port, err := strconv.Atoi(env.GetEnv("API_PORT", "8080"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error listening port: %v, err: %v", port, err)
|
log.Fatalf("error listening port: %v, err: %v", port, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
pb "fastbin/api/keygen"
|
pb "fastbin/api/keygen"
|
||||||
|
|
||||||
|
"fastbin/internal/pkg/env"
|
||||||
paste "fastbin/internal/pkg/paste"
|
paste "fastbin/internal/pkg/paste"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"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) {
|
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()))
|
conn, err := grpc.NewClient(grpcServerURL, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
|
||||||
12
syntax.env
12
syntax.env
|
|
@ -1,7 +1,13 @@
|
||||||
|
WEB_PORT=8082
|
||||||
|
|
||||||
API_PORT=8080
|
API_PORT=8080
|
||||||
WEB_PORT=8081
|
API_HOST=localhost
|
||||||
DB_HOST=localhost
|
|
||||||
|
KEYGEN_PORT=8081
|
||||||
|
KEYGEN_HOST=localhost
|
||||||
|
|
||||||
DB_PORT=5432
|
DB_PORT=5432
|
||||||
|
DB_HOST=localhost
|
||||||
DB_DATABASE=fastbin
|
DB_DATABASE=fastbin
|
||||||
DB_USERNAME=username
|
DB_USERNAME=username
|
||||||
DB_PASSWORD=password
|
DB_PASSWORD=password
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue