|
@ -1,16 +1,37 @@ |
|
|
package main |
|
|
package main |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
_ "practice_Go/internal/logic" |
|
|
|
|
|
_ "practice_Go/internal/packed" |
|
|
|
|
|
|
|
|
_ "practice_Go/internal/logic" |
|
|
|
|
|
_ "practice_Go/internal/packed" |
|
|
|
|
|
|
|
|
_ "github.com/gogf/gf/contrib/drivers/mysql/v2" |
|
|
|
|
|
|
|
|
"github.com/gogf/gf/v2/os/gctx" |
|
|
|
|
|
|
|
|
"github.com/gogf/gf/v2/os/gctx" |
|
|
|
|
|
|
|
|
_ "github.com/gogf/gf/contrib/drivers/mysql/v2" |
|
|
|
|
|
|
|
|
"practice_Go/internal/cmd" |
|
|
|
|
|
|
|
|
"practice_Go/internal/cmd" |
|
|
|
|
|
|
|
|
|
|
|
"fmt" |
|
|
|
|
|
"log" |
|
|
|
|
|
"net/http" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/rs/cors" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func main() { |
|
|
func main() { |
|
|
cmd.Main.Run(gctx.GetInitCtx()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
cmd.Main.Run(gctx.GetInitCtx()) |
|
|
|
|
|
|
|
|
|
|
|
mux := http.NewServeMux() |
|
|
|
|
|
mux.HandleFunc("/mainpage/get-shows", func(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
fmt.Fprintln(w, "Show data") |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// 创建CORS中间件,配置允许的源等信息
|
|
|
|
|
|
c := cors.New(cors.Options{ |
|
|
|
|
|
AllowedOrigins: []string{"http://localhost:5173"}, |
|
|
|
|
|
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"}, |
|
|
|
|
|
AllowedHeaders: []string{"Content-Type"}, |
|
|
|
|
|
}) |
|
|
|
|
|
handler := c.Handler(mux) |
|
|
|
|
|
log.Fatal(http.ListenAndServe(":8080", handler)) |
|
|
|
|
|
|
|
|
|
|
|
} |