静态前端

This commit is contained in:
2023-06-18 12:25:04 +08:00
parent 54c2396e66
commit 02e76feee9

View File

@@ -34,8 +34,11 @@ func main() {
}) })
}) })
// 設定靜態資源 (前端) 位于public目录下
r.PathPrefix("/").Handler(http.FileServer(http.Dir("./public/")))
// 設定路由 // 設定路由
r.HandleFunc("/", routers.GetDocs).Methods("GET") r.HandleFunc("/api", routers.GetDocs).Methods("GET")
r.HandleFunc("/api/users", routers.UsersGet).Methods("GET") r.HandleFunc("/api/users", routers.UsersGet).Methods("GET")
r.HandleFunc("/api/users", routers.UsersPost).Methods("POST") r.HandleFunc("/api/users", routers.UsersPost).Methods("POST")