static_router.go 557 字节
package routers

import (
	"net/http"

	"github.com/astaxie/beego"
	"github.com/astaxie/beego/context"
	"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant"
)

func init() {
	//beego.SetStaticPath("/log", constant.LOG_File)
	beego.Get("/log", func(ctx *context.Context) {
		var s string
		ctx.Input.Bind(&s, "id")
		if s != "12345" {
			ctx.Output.SetStatus(http.StatusBadRequest)
			return
		}
		http.ServeFile(ctx.ResponseWriter, ctx.Request, constant.LOG_File)
		return
	})

	// 静态文件路径映射
	beego.SetStaticPath("/download", "download")
}