(u *url.URL, logger *clog.CondLogger)
| 26 | } |
| 27 | |
| 28 | func NewStaticResponse(u *url.URL, logger *clog.CondLogger) (*StaticRejectAuth, error) { |
| 29 | values, err := url.ParseQuery(u.RawQuery) |
| 30 | if err != nil { |
| 31 | return nil, err |
| 32 | } |
| 33 | code := 403 |
| 34 | if values.Has("code") { |
| 35 | parsedCode, err := strconv.Atoi(values.Get("code")) |
| 36 | if err != nil { |
| 37 | return nil, fmt.Errorf("unable to parse code parameter: %w", err) |
| 38 | } |
| 39 | code = parsedCode |
| 40 | } |
| 41 | return &StaticRejectAuth{ |
| 42 | code: code, |
| 43 | body: values.Get("body"), |
| 44 | hdrs: values.Get("headers"), |
| 45 | logger: logger, |
| 46 | }, nil |
| 47 | } |
| 48 | |
| 49 | func (a *StaticRejectAuth) Validate(ctx context.Context, w http.ResponseWriter, r *http.Request) (string, bool) { |
| 50 | if a.hdrs != "" { |
no test coverage detected