From 02e76feee9af4b2c92d18e115769defe60fd9193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=9C=E8=8F=AF?= Date: Sun, 18 Jun 2023 12:25:04 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=99=E6=80=81=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index fe69abf..49d36e5 100644 --- a/main.go +++ b/main.go @@ -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.UsersPost).Methods("POST")