Commit 2c8cb569 authored by nkbai's avatar nkbai

windows下静态文件映射找不到问题,

path.Clean和filepath.Clean是有区别的
parent d693ecf0
...@@ -18,20 +18,18 @@ import ( ...@@ -18,20 +18,18 @@ import (
"net/http" "net/http"
"os" "os"
"path" "path"
"path/filepath"
"strconv" "strconv"
"strings" "strings"
"github.com/astaxie/beego/context" "github.com/astaxie/beego/context"
"github.com/astaxie/beego/utils" "github.com/astaxie/beego/utils"
) )
func serverStaticRouter(ctx *context.Context) { func serverStaticRouter(ctx *context.Context) {
if ctx.Input.Method() != "GET" && ctx.Input.Method() != "HEAD" { if ctx.Input.Method() != "GET" && ctx.Input.Method() != "HEAD" {
return return
} }
requestPath := filepath.Clean(ctx.Input.Request.URL.Path) requestPath := path.Clean(ctx.Input.Request.URL.Path)
// special processing : favicon.ico/robots.txt can be in any static dir // special processing : favicon.ico/robots.txt can be in any static dir
if requestPath == "/favicon.ico" || requestPath == "/robots.txt" { if requestPath == "/favicon.ico" || requestPath == "/robots.txt" {
file := path.Join(".", requestPath) file := path.Join(".", requestPath)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment