publish
This commit is contained in:
@@ -11,7 +11,8 @@ import (
|
||||
var MssqlDB *sql.DB
|
||||
|
||||
func ConnectMSSQL() {
|
||||
connString := "sqlserver://sa:Gil_0150@10.0.0.9:1433?databaseName=BAGGI_V3"
|
||||
//connString := "sqlserver://sa:Gil_0150@10.0.0.9:1433?databaseName=BAGGI_V3"
|
||||
connString := "sqlserver://sa:Gil_0150@100.127.221.13:1433?databaseName=BAGGI_V3"
|
||||
|
||||
var err error
|
||||
MssqlDB, err = sql.Open("sqlserver", connString)
|
||||
|
||||
@@ -18,7 +18,8 @@ func ConnectPostgres() (*sql.DB, error) {
|
||||
connStr := os.Getenv("POSTGRES_CONN")
|
||||
if connStr == "" {
|
||||
// fallback → sabit tanımlı bağlantı
|
||||
connStr = "host=172.16.0.3 port=5432 user=postgres password=tayitkan dbname=baggib2b sslmode=disable"
|
||||
connStr = "host=127.0.0.1 port=5432 user=postgres password=tayitkan dbname=baggib2b sslmode=disable"
|
||||
//connStr = "host=172.16.0.3 port=5432 user=postgres password=tayitkan dbname=baggib2b sslmode=disable"
|
||||
}
|
||||
|
||||
db, err := sql.Open("postgres", connStr)
|
||||
|
||||
51
svc/main.go
51
svc/main.go
@@ -143,6 +143,7 @@ InitRoutes — FULL V3 (Method-aware) PERMISSION EDITION
|
||||
func InitRoutes(pgDB *sql.DB, mssql *sql.DB, ml *mailer.GraphMailer) *mux.Router {
|
||||
|
||||
r := mux.NewRouter()
|
||||
mountSPA(r)
|
||||
|
||||
/*
|
||||
===========================================================
|
||||
@@ -592,3 +593,53 @@ func main() {
|
||||
log.Println("✅ Server çalışıyor: http://localhost:8080")
|
||||
log.Fatal(http.ListenAndServe(":8080", handler))
|
||||
}
|
||||
|
||||
func mountSPA(m gorilla.Mux) {
|
||||
m.Group(func(r chi.Router) {
|
||||
r.NotFound(spaIndex)
|
||||
r.Get("/", spaIndex)
|
||||
})
|
||||
}
|
||||
|
||||
func spaIndex(w http.ResponseWriter, r *http.Request) {
|
||||
p := r.URL.Path
|
||||
|
||||
if r.URL.Path == "/logo.png" {
|
||||
_, err := os.Stat("./logo.png")
|
||||
if err == nil {
|
||||
http.ServeFile(w, r, "./logo.png")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(p, "/") {
|
||||
p = "/" + p
|
||||
r.URL.Path = p
|
||||
}
|
||||
p = path.Clean(p)
|
||||
if p == "/" {
|
||||
p = "index.html"
|
||||
}
|
||||
|
||||
if strings.HasPrefix(p, "/api") {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
name := path.Join(app.RUN.UiDir, filepath.FromSlash(p))
|
||||
|
||||
f, err := os.Stat(name)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
http.ServeFile(w, r, fmt.Sprintf("%s/index.html", app.RUN.UiDir))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if f.IsDir() {
|
||||
Forbidden(w, nil)
|
||||
return
|
||||
}
|
||||
|
||||
http.ServeFile(w, r, name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user