Env variables added
This commit is contained in:
@@ -6,10 +6,13 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/go-chi/cors"
|
||||
@@ -1017,6 +1020,18 @@ func server(app *App) *http.Server {
|
||||
}
|
||||
|
||||
func main() {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Println("Cannot find .env file, using system env variables")
|
||||
}
|
||||
|
||||
adminUser := os.Getenv("ADMIN_USER")
|
||||
adminPass := os.Getenv("ADMIN_PASS")
|
||||
|
||||
if adminUser == "" || adminPass == "" {
|
||||
log.Fatal("No ADMIN_USER or ADMIN_PASS env variable set")
|
||||
}
|
||||
|
||||
db := database()
|
||||
defer db.Close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user