mirror of
https://github.com/Macrame-App/Macrame
synced 2025-12-29 07:19:26 +00:00
Alpha version be update
This commit is contained in:
parent
f5f6f25a4a
commit
e1b13b3930
12 changed files with 86 additions and 42 deletions
22
be/main.go
22
be/main.go
|
|
@ -3,6 +3,8 @@ package main
|
|||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"be/app"
|
||||
"be/app/helper"
|
||||
|
|
@ -11,6 +13,8 @@ import (
|
|||
func main() {
|
||||
app.MCRMLogInit()
|
||||
|
||||
switchToBeDir()
|
||||
|
||||
if helper.EnvGet("MCRM__PORT") == "" {
|
||||
app.MCRMLog("Error: MCRM__PORT is not set")
|
||||
}
|
||||
|
|
@ -19,19 +23,29 @@ func main() {
|
|||
apiInit(w, r)
|
||||
})
|
||||
|
||||
log.Println("Listening on http://localhost:" + helper.EnvGet("MCRM__PORT"))
|
||||
// helper.OpenBrowser("http://localhost:" + helper.EnvGet("MCRM__PORT"))
|
||||
|
||||
helper.OpenBrowser("http://localhost:" + helper.EnvGet("MCRM__PORT"))
|
||||
app.MCRMLog("Listening on http://localhost:" + helper.EnvGet("MCRM__PORT"))
|
||||
|
||||
app.MCRMLog(http.ListenAndServe(":"+helper.EnvGet("MCRM__PORT"), nil))
|
||||
}
|
||||
|
||||
func switchToBeDir() {
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if !strings.HasSuffix(cwd, "be") {
|
||||
err := os.Chdir("be")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func apiInit(w http.ResponseWriter, r *http.Request) {
|
||||
app.ApiCORS(w, r)
|
||||
|
||||
app.MCRMLog("Remote IP: " + r.RemoteAddr)
|
||||
|
||||
if r.Method == "GET" {
|
||||
app.ApiGet(w, r)
|
||||
} else if r.Method == "POST" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue