You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
852 B
37 lines
852 B
package main
|
|
|
|
import (
|
|
_ "practice_Go/internal/logic"
|
|
_ "practice_Go/internal/packed"
|
|
|
|
"github.com/gogf/gf/v2/os/gctx"
|
|
|
|
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
|
|
|
|
"practice_Go/internal/cmd"
|
|
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
|
|
"github.com/rs/cors"
|
|
)
|
|
|
|
func main() {
|
|
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))
|
|
|
|
}
|