mirror of
https://github.com/alexgo-io/gaze-brc20-indexer.git
synced 2026-01-12 14:34:54 +08:00
feat: move requestip config to http config (#25)
This commit is contained in:
committed by
GitHub
parent
a7bc6257c4
commit
51fd1f6636
@@ -145,7 +145,7 @@ func runHandler(cmd *cobra.Command, _ []string) error {
|
|||||||
Use(requestid.New()).
|
Use(requestid.New()).
|
||||||
Use(requestcontext.New(
|
Use(requestcontext.New(
|
||||||
requestcontext.WithRequestId(),
|
requestcontext.WithRequestId(),
|
||||||
requestcontext.WithClientIP(conf.RequestIP),
|
requestcontext.WithClientIP(conf.HTTPServer.RequestIP),
|
||||||
)).
|
)).
|
||||||
Use(requestlogger.New(conf.HTTPServer.Logger)).
|
Use(requestlogger.New(conf.HTTPServer.Logger)).
|
||||||
Use(fiberrecover.New(fiberrecover.Config{
|
Use(fiberrecover.New(fiberrecover.Config{
|
||||||
|
|||||||
@@ -27,13 +27,10 @@ http_server:
|
|||||||
disable: false # disable logger if logger level is `INFO`
|
disable: false # disable logger if logger level is `INFO`
|
||||||
request_header: false
|
request_header: false
|
||||||
request_query: false
|
request_query: false
|
||||||
|
requestip: # Client IP extraction configuration options. This is unnecessary if you don't care about the real client IP or if you're not using a reverse proxy.
|
||||||
# Client IP extraction configuration options.
|
trusted_proxies_ip: # Cloudflare, GCP Public LB. See: server/internal/middleware/requestcontext/PROXY-IP.md
|
||||||
# This is unnecessary if you don't care about the real client IP or if you're not using a reverse proxy.
|
trusted_proxies_header: # X-Real-IP, CF-Connecting-IP
|
||||||
requestip:
|
enable_reject_malformed_request: false # return 403 if request is malformed (invalid IP)
|
||||||
trusted_proxies_ip: # Cloudflare, GCP Public LB. See: server/internal/middleware/requestcontext/PROXY-IP.md
|
|
||||||
trusted_proxies_header: # X-Real-IP, CF-Connecting-IP
|
|
||||||
enable_reject_malformed_request: false # return 403 if request is malformed (invalid IP)
|
|
||||||
|
|
||||||
# Meta-protocol modules configuration options.
|
# Meta-protocol modules configuration options.
|
||||||
modules:
|
modules:
|
||||||
|
|||||||
@@ -43,15 +43,14 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
EnableModules []string `mapstructure:"enable_modules"`
|
EnableModules []string `mapstructure:"enable_modules"`
|
||||||
APIOnly bool `mapstructure:"api_only"`
|
APIOnly bool `mapstructure:"api_only"`
|
||||||
Logger logger.Config `mapstructure:"logger"`
|
Logger logger.Config `mapstructure:"logger"`
|
||||||
BitcoinNode BitcoinNodeClient `mapstructure:"bitcoin_node"`
|
BitcoinNode BitcoinNodeClient `mapstructure:"bitcoin_node"`
|
||||||
Network common.Network `mapstructure:"network"`
|
Network common.Network `mapstructure:"network"`
|
||||||
HTTPServer HTTPServerConfig `mapstructure:"http_server"`
|
HTTPServer HTTPServerConfig `mapstructure:"http_server"`
|
||||||
Modules Modules `mapstructure:"modules"`
|
Modules Modules `mapstructure:"modules"`
|
||||||
Reporting reportingclient.Config `mapstructure:"reporting"`
|
Reporting reportingclient.Config `mapstructure:"reporting"`
|
||||||
RequestIP requestcontext.WithClientIPConfig `mapstructure:"requestip"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type BitcoinNodeClient struct {
|
type BitcoinNodeClient struct {
|
||||||
@@ -66,8 +65,9 @@ type Modules struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type HTTPServerConfig struct {
|
type HTTPServerConfig struct {
|
||||||
Port int `mapstructure:"port"`
|
Port int `mapstructure:"port"`
|
||||||
Logger requestlogger.Config `mapstructure:"logger"`
|
Logger requestlogger.Config `mapstructure:"logger"`
|
||||||
|
RequestIP requestcontext.WithClientIPConfig `mapstructure:"requestip"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse parse the configuration from environment variables
|
// Parse parse the configuration from environment variables
|
||||||
|
|||||||
Reference in New Issue
Block a user