File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import (
1414)
1515
1616var TimeValidity int64
17+ var MAX_ALLOWED_TIME int64 = 24 // in hrs
1718
1819type ArcUsage struct {
1920 ArcID string `json:"arc_id"`
@@ -42,11 +43,13 @@ const (
4243// Middleware function, which will be called for each request
4344func BillingMiddleware (next http.Handler ) http.Handler {
4445 return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
45- // Valid plan
46- if TimeValidity > 0 {
47- // Check if remaining time is less than 24 hrs
48- if TimeValidity <= 3600 * 24 {
49- // Print warning message if remaining time is less than 24 hrs
46+ if TimeValidity > 0 { // Valid plan
47+ next .ServeHTTP (w , r )
48+ } else if - (TimeValidity ) <= 3600 * MAX_ALLOWED_TIME {
49+ // Print warning message if remaining time is less than max allowed time
50+ if TimeValidity == 0 { // Rare, but it can happen when tier has been just expired
51+ log .Println ("warning: payment required. arc will start sending out error messages in some time" )
52+ } else {
5053 log .Println ("warning: payment required. arc will start sending out error messages in next" , TimeValidity / 3600 , "hours" )
5154 }
5255 next .ServeHTTP (w , r )
You can’t perform that action at this time.
0 commit comments