improve package gcfg for searching priority

This commit is contained in:
John Guo 2021-01-16 22:31:48 +08:00
parent 1e309e570d
commit 91e29e23a4
3 changed files with 10 additions and 10 deletions

View File

@ -1,4 +1,4 @@
// Copyright GoFrame Author(https://github.com/gogf/gf). All Rights Reserved.
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
@ -8,14 +8,14 @@ package ghttp
import "net/http"
// WrapF is a helper function for wrapping http.HandlerFunc and returns a ghttp middleware.
// WrapF is a helper function for wrapping http.HandlerFunc and returns a ghttp.HandlerFunc.
func WrapF(f http.HandlerFunc) HandlerFunc {
return func(r *Request) {
f(r.Response.Writer, r.Request)
}
}
// WrapH is a helper function for wrapping http.Handler and returns a ghttp middleware.
// WrapH is a helper function for wrapping http.Handler and returns a ghttp.HandlerFunc.
func WrapH(h http.Handler) HandlerFunc {
return func(r *Request) {
h.ServeHTTP(r.Response.Writer, r.Request)

View File

@ -1,4 +1,4 @@
// Copyright 2018 gf Author(https://github.com/gogf/gf). All Rights Reserved.
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,

View File

@ -70,16 +70,16 @@ func New(file ...string) *Config {
}
}
} else {
// Dir path of working dir.
_ = c.SetPath(gfile.Pwd())
// Dir path of binary.
if selfPath := gfile.SelfDir(); selfPath != "" && gfile.Exists(selfPath) {
_ = c.AddPath(selfPath)
}
// Dir path of main package.
if mainPath := gfile.MainPkgPath(); mainPath != "" && gfile.Exists(mainPath) {
_ = c.AddPath(mainPath)
}
// Dir path of binary.
if selfPath := gfile.SelfDir(); selfPath != "" && gfile.Exists(selfPath) {
_ = c.AddPath(selfPath)
}
// Dir path of working dir.
_ = c.AddPath(gfile.Pwd())
}
return c
}