-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(plugins): traefik and caddy to use Storers
- Loading branch information
Showing
24 changed files
with
1,242 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package context | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
|
||
"github.com/darkweak/souin/configurationtypes" | ||
) | ||
|
||
const Mode ctxKey = "souin_ctx.MODE" | ||
|
||
type ModeContext struct { | ||
Strict, Bypass_request, Bypass_response bool | ||
} | ||
|
||
func (mc *ModeContext) SetupContext(c configurationtypes.AbstractConfigurationInterface) { | ||
mode := c.GetDefaultCache().GetMode() | ||
mc.Bypass_request = mode == "bypass" || mode == "bypass_request" | ||
mc.Bypass_response = mode == "bypass" || mode == "bypass_response" | ||
mc.Strict = !mc.Bypass_request && !mc.Bypass_response | ||
} | ||
|
||
func (mc *ModeContext) SetContext(req *http.Request) *http.Request { | ||
return req.WithContext(context.WithValue(req.Context(), Mode, mc)) | ||
} | ||
|
||
var _ ctx = (*cacheContext)(nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package context | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"time" | ||
|
||
"github.com/darkweak/souin/configurationtypes" | ||
) | ||
|
||
const Now ctxKey = "souin_ctx.NOW" | ||
|
||
type nowContext struct{} | ||
|
||
func (cc *nowContext) SetupContext(_ configurationtypes.AbstractConfigurationInterface) {} | ||
|
||
func (cc *nowContext) SetContext(req *http.Request) *http.Request { | ||
now := time.Now().UTC() | ||
req.Header.Set("Date", now.Format(time.RFC1123)) | ||
return req.WithContext(context.WithValue(req.Context(), Now, now)) | ||
} | ||
|
||
var _ ctx = (*nowContext)(nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.