Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
feat: add GasConfig.Skippable
Browse files Browse the repository at this point in the history
  • Loading branch information
aofei committed Jul 23, 2019
1 parent 25d86ed commit 0cb3e43
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hstsman.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
type GasConfig struct {
MaxAge int
IncludeSubDomains bool

Skippable func(*air.Request, *air.Response) bool
}

// Gas returns an `air.Gas` that is used to manage the Strict-Transport-Security
Expand All @@ -29,6 +31,10 @@ func Gas(gc GasConfig) air.Gas {

return func(next air.Handler) air.Handler {
return func(req *air.Request, res *air.Response) error {
if gc.Skippable != nil && gc.Skippable(req, res) {
return next(req, res)
}

if req.Air.HTTPSEnforced {
res.Header.Set(
"Strict-Transport-Security",
Expand Down

0 comments on commit 0cb3e43

Please sign in to comment.