Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ type APIImpl struct {
throttlerCheck *throttle.ThrottlerCheck
consensusService group.ConsensusService
hostname string
bypassEnabled bool
}

// NewAPIImpl creates a new instance of the API implementation
func NewAPIImpl(throttlerCheck *throttle.ThrottlerCheck, consensusService group.ConsensusService) *APIImpl {
bypassEnabled := (os.Getenv("FRENO_BYPASS_ENABLED") != "")
Comment thread
meiji163 marked this conversation as resolved.
Outdated
api := &APIImpl{
throttlerCheck: throttlerCheck,
consensusService: consensusService,
bypassEnabled: bypassEnabled,
}
if hostname, err := os.Hostname(); err == nil {
api.hostname = hostname
Expand Down Expand Up @@ -165,6 +168,12 @@ func (api *APIImpl) check(w http.ResponseWriter, r *http.Request, ps httprouter.
}
flags.LowPriority = (r.URL.Query().Get("p") == "low")

if api.bypassEnabled {
Comment thread
meiji163 marked this conversation as resolved.
Outdated
checkResult := throttle.NewCheckResult(http.StatusOK, 0, 0, nil)
api.respondToCheckRequest(w, r, checkResult)
return
}

checkResult := api.throttlerCheck.Check(appName, storeType, storeName, remoteAddr, flags)
if checkResult.StatusCode == http.StatusNotFound && flags.OKIfNotExists {
checkResult.StatusCode = http.StatusOK // 200
Expand Down
Loading