mirror of
https://github.com/httpjamesm/AnonymousOverflow.git
synced 2025-04-22 23:09:15 +00:00
feat: host and port envs
This commit is contained in:
parent
0cc87360b4
commit
fd6ca8b56a
1 changed files with 13 additions and 1 deletions
14
main.go
14
main.go
|
@ -3,6 +3,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"anonymousoverflow/src/middleware"
|
"anonymousoverflow/src/middleware"
|
||||||
"anonymousoverflow/src/routes"
|
"anonymousoverflow/src/routes"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
@ -30,5 +32,15 @@ func main() {
|
||||||
|
|
||||||
r.GET("/questions/:id/:title", routes.ViewQuestion)
|
r.GET("/questions/:id/:title", routes.ViewQuestion)
|
||||||
|
|
||||||
r.Run("localhost:8080")
|
host := os.Getenv("HOST")
|
||||||
|
if host == "" {
|
||||||
|
host = "0.0.0.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
port := os.Getenv("PORT")
|
||||||
|
if port == "" {
|
||||||
|
port = "8080"
|
||||||
|
}
|
||||||
|
|
||||||
|
r.Run(fmt.Sprintf("%s:%s", host, port))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue