mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 01:10:54 +00:00
Merge pull request #4239 from flycash/rft/httplib
decouple httplib module from web module and config module
This commit is contained in:
commit
325a0821c1
@ -23,11 +23,13 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
"github.com/astaxie/beego/pkg/client/httplib"
|
"github.com/astaxie/beego/pkg/client/httplib"
|
||||||
"github.com/astaxie/beego/pkg/server/web"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type FilterChainBuilder struct {
|
type FilterChainBuilder struct {
|
||||||
summaryVec prometheus.ObserverVec
|
summaryVec prometheus.ObserverVec
|
||||||
|
AppName string
|
||||||
|
ServerName string
|
||||||
|
RunMode string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (builder *FilterChainBuilder) FilterChain(next httplib.Filter) httplib.Filter {
|
func (builder *FilterChainBuilder) FilterChain(next httplib.Filter) httplib.Filter {
|
||||||
@ -36,9 +38,9 @@ func (builder *FilterChainBuilder) FilterChain(next httplib.Filter) httplib.Filt
|
|||||||
Name: "beego",
|
Name: "beego",
|
||||||
Subsystem: "remote_http_request",
|
Subsystem: "remote_http_request",
|
||||||
ConstLabels: map[string]string{
|
ConstLabels: map[string]string{
|
||||||
"server": web.BConfig.ServerName,
|
"server": builder.ServerName,
|
||||||
"env": web.BConfig.RunMode,
|
"env": builder.RunMode,
|
||||||
"appname": web.BConfig.AppName,
|
"appname": builder.AppName,
|
||||||
},
|
},
|
||||||
Help: "The statics info for remote http requests",
|
Help: "The statics info for remote http requests",
|
||||||
}, []string{"proto", "scheme", "method", "host", "path", "status", "duration", "isError"})
|
}, []string{"proto", "scheme", "method", "host", "path", "status", "duration", "isError"})
|
||||||
|
@ -16,8 +16,6 @@ package testing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego/pkg/client/httplib"
|
"github.com/astaxie/beego/pkg/client/httplib"
|
||||||
|
|
||||||
"github.com/astaxie/beego/pkg/infrastructure/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var port = ""
|
var port = ""
|
||||||
@ -28,16 +26,13 @@ type TestHTTPRequest struct {
|
|||||||
httplib.BeegoHTTPRequest
|
httplib.BeegoHTTPRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetTestingPort(p string) {
|
||||||
|
port = p
|
||||||
|
}
|
||||||
|
|
||||||
func getPort() string {
|
func getPort() string {
|
||||||
if port == "" {
|
if port == "" {
|
||||||
config, err := config.NewConfig("ini", "../conf/app.conf")
|
port = "8080"
|
||||||
if err != nil {
|
|
||||||
return "8080"
|
|
||||||
}
|
|
||||||
port, err = config.String(nil, "httpport")
|
|
||||||
if err != nil {
|
|
||||||
return "8080"
|
|
||||||
}
|
|
||||||
return port
|
return port
|
||||||
}
|
}
|
||||||
return port
|
return port
|
||||||
|
Loading…
Reference in New Issue
Block a user