Skip to content

Commit

Permalink
chore: remove toggle for requestID
Browse files Browse the repository at this point in the history
  • Loading branch information
theSuess committed May 7, 2023
1 parent 3184773 commit af967e2
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 38 deletions.
5 changes: 2 additions & 3 deletions cmd/gotosocial/action/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,8 @@ var Start action.GTSAction = func(ctx context.Context) error {
return fmt.Errorf("error creating router: %s", err)
}

middlewares := []gin.HandlerFunc{}
if config.GetRequestIDEnabled() {
middlewares = append(middlewares, middleware.AddRequestID(config.GetRequestIDHeader()))
middlewares := []gin.HandlerFunc{
middleware.AddRequestID(config.GetRequestIDHeader()), // requestID middleware must run before tracing
}
if config.GetTracingEnabled() {
middlewares = append(middlewares, tracing.InstrumentGin())
Expand Down
5 changes: 2 additions & 3 deletions cmd/gotosocial/action/testrig/testrig.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ var Start action.GTSAction = func(ctx context.Context) error {
*/

router := testrig.NewTestRouter(state.DB)
middlewares := []gin.HandlerFunc{}
if config.GetRequestIDEnabled() {
middlewares = append(middlewares, middleware.AddRequestID(config.GetRequestIDHeader()))
middlewares := []gin.HandlerFunc{
middleware.AddRequestID(config.GetRequestIDHeader()), // requestID middleware must run before tracing
}
if config.GetTracingEnabled() {
middlewares = append(middlewares, tracing.InstrumentGin())
Expand Down
3 changes: 1 addition & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ type Configuration struct {
AdminTransPath string `name:"path" usage:"the path of the file to import from/export to"`
AdminMediaPruneDryRun bool `name:"dry-run" usage:"perform a dry run and only log number of items eligible for pruning"`

RequestIDEnabled bool `name:"request-id-enabled" usage:"Enable the usage of a request id header which can be passed by external proxies."`
RequestIDHeader string `name:"request-id-header" usage:"Header to extract the Request ID from. Eg.,'X-Request-Id'."`
RequestIDHeader string `name:"request-id-header" usage:"Header to extract the Request ID from. Eg.,'X-Request-Id'."`
}

type CacheConfiguration struct {
Expand Down
3 changes: 1 addition & 2 deletions internal/config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,5 @@ var Defaults = Configuration{

AdminMediaPruneDryRun: true,

RequestIDEnabled: true,
RequestIDHeader: "X-Request-Id",
RequestIDHeader: "X-Request-Id",
}
25 changes: 0 additions & 25 deletions internal/config/helpers.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -3630,31 +3630,6 @@ func GetAdminMediaPruneDryRun() bool { return global.GetAdminMediaPruneDryRun()
// SetAdminMediaPruneDryRun safely sets the value for global configuration 'AdminMediaPruneDryRun' field
func SetAdminMediaPruneDryRun(v bool) { global.SetAdminMediaPruneDryRun(v) }

// GetRequestIDEnabled safely fetches the Configuration value for state's 'RequestIDEnabled' field
func (st *ConfigState) GetRequestIDEnabled() (v bool) {
st.mutex.Lock()
v = st.config.RequestIDEnabled
st.mutex.Unlock()
return
}

// SetRequestIDEnabled safely sets the Configuration value for state's 'RequestIDEnabled' field
func (st *ConfigState) SetRequestIDEnabled(v bool) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.RequestIDEnabled = v
st.reloadToViper()
}

// RequestIDEnabledFlag returns the flag name for the 'RequestIDEnabled' field
func RequestIDEnabledFlag() string { return "request-id-enabled" }

// GetRequestIDEnabled safely fetches the value for global configuration 'RequestIDEnabled' field
func GetRequestIDEnabled() bool { return global.GetRequestIDEnabled() }

// SetRequestIDEnabled safely sets the value for global configuration 'RequestIDEnabled' field
func SetRequestIDEnabled(v bool) { global.SetRequestIDEnabled(v) }

// GetRequestIDHeader safely fetches the Configuration value for state's 'RequestIDHeader' field
func (st *ConfigState) GetRequestIDHeader() (v string) {
st.mutex.Lock()
Expand Down
1 change: 0 additions & 1 deletion test/envparsing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ EXPECT=$(cat <<"EOF"
"path": "",
"port": 6969,
"protocol": "http",
"request-id-enabled": true,
"request-id-header": "X-Trace-Id",
"smtp-disclose-recipients": true,
"smtp-from": "[email protected]",
Expand Down
2 changes: 0 additions & 2 deletions testrig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ var testDefaults = config.Configuration{
TracingTransport: "grpc",
TracingInsecureTransport: true,

RequestIDEnabled: true,

SyslogEnabled: false,
SyslogProtocol: "udp",
SyslogAddress: "localhost:514",
Expand Down

0 comments on commit af967e2

Please sign in to comment.