MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / NewStaticResponse

Function NewStaticResponse

auth/rejectstatic.go:28–47  ·  view source on GitHub ↗
(u *url.URL, logger *clog.CondLogger)

Source from the content-addressed store, hash-verified

26}
27
28func 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
49func (a *StaticRejectAuth) Validate(ctx context.Context, w http.ResponseWriter, r *http.Request) (string, bool) {
50 if a.hdrs != "" {

Callers 2

NewResponseFunction · 0.85
NewStaticRejectAuthFunction · 0.85

Calls 3

ErrorfMethod · 0.80
HasMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected