Add more term fixes and markdown format fixes
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
## beego 靜態檔案實現和設定
|
||||
Go 的 net/http 套件中提供了靜態檔案的服務,`ServeFile`和 `FileServer` 等函式。beego 的靜態檔案處理就是基於這一層處理的,具體的實現如下所示:
|
||||
|
||||
```Go
|
||||
|
||||
//static file server
|
||||
@@ -18,6 +19,7 @@ for prefix, staticDir := range StaticDir {
|
||||
StaticDir 裡面儲存的是相應的 url 對應到靜態檔案所在的目錄,因此在處理 URL 請求的時候只需要判斷對應的請求地址是否包含靜態處理開頭的 url,如果包含的話就採用 http.ServeFile 提供服務。
|
||||
|
||||
舉例如下:
|
||||
|
||||
```Go
|
||||
|
||||
beego.StaticDir["/asset"] = "/static"
|
||||
@@ -49,6 +51,7 @@ Bootstrap 是 Twitter 推出的一個開源的用於前端開發的工具套件
|
||||
圖 14.2 專案中靜態檔案目錄結構
|
||||
|
||||
2. 因為 beego 預設設定了 StaticDir 的值,所以如果你的靜態檔案目錄是 static 的話就無須再增加了:
|
||||
|
||||
```Go
|
||||
|
||||
StaticDir["/static"] = "static"
|
||||
|
||||
Reference in New Issue
Block a user