第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

FileServe和Routing的更流暢配合

FileServe和Routing的更流暢配合

Go
皈依舞 2021-10-25 16:55:37
我有一個(gè)問題,我想在 FileServe 上提供我的主要 AngularJS(Yeoman 部署)應(yīng)用程序文件夾,/但它會(huì)破壞我所有的路由器綁定。有什么辦法可以保留它們并保持我的路線完好無損?在下面的代碼中,我仍然需要去/app重新綁定其他文件夾,因?yàn)槲也幌脒^多地調(diào)整 Grunt 文件(還),所以為文件夾添加了一些額外的備份路徑綁定。func initializeRoutes() {    // Handle all requests by serving a file of the same name    fileHandler := http.FileServer(http.Dir(*clFlagStaticDirectory))    bowerFileHandler := http.FileServer(http.Dir("../bower_components"))    imagesFileHandler := http.FileServer(http.Dir("../app/images"))    scriptsFileHandler := http.FileServer(http.Dir("../app/scripts"))    stylesFileHandler := http.FileServer(http.Dir("../app/styles"))    viewsFileHandler := http.FileServer(http.Dir("../app/views"))    // Setup routes    mainRoute := mux.NewRouter()    mainRoute.StrictSlash(true)    // mainRoute.Handle("/", http.RedirectHandler("/static/", 302))    mainRoute.PathPrefix("/app").Handler(http.StripPrefix("/app", fileHandler))    mainRoute.PathPrefix("/app/bower_components").Handler(http.StripPrefix("/bower_components", bowerFileHandler))    mainRoute.PathPrefix("/bower_components").Handler(http.StripPrefix("/bower_components", bowerFileHandler))    mainRoute.PathPrefix("/images").Handler(http.StripPrefix("/images", imagesFileHandler))    mainRoute.PathPrefix("/scripts").Handler(http.StripPrefix("/scripts", scriptsFileHandler))    mainRoute.PathPrefix("/styles").Handler(http.StripPrefix("/styles", stylesFileHandler))    mainRoute.PathPrefix("/views").Handler(http.StripPrefix("/views", viewsFileHandler))    // Basic routes    // User routes    userRoute := mainRoute.PathPrefix("/users").Subrouter()    userRoute.Handle("/login", handler(userDoLogin)).Methods("POST")    userRoute.Handle("/logout", handler(userDoLogout)).Methods("GET")    userRoute.Handle("/forgot_password", handler(forgotPassword)).Methods("POST")}所以我的目標(biāo)是/app作為我的/主要路徑,但保留我所有的 Mux 路由來贏得 FileServe。所以如果我有一個(gè)/app/users/login文件夾,它不會(huì)加載,而是會(huì)讓路由器獲勝。注意:我的服務(wù)純粹是結(jié)束HTTPS而不是結(jié)束HTTP。非常感謝!這打破了我的大腦,這是我在完全開始我的前端代碼之前需要弄清楚的最后一件事:)。
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 217 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)