Skip to content

Commit

Permalink
what is wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
1lann committed Jan 5, 2024
1 parent 2dcb45b commit decc88e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mini.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ func NewMini(config MiniConfig, next CaddyHandleFunc) (*Tmpauth, error) {
doneOnce: sync.Once{},
}

transport := (http.RoundTripper)(&MiniTransport{
transport := &MiniTransport{
RoundTripper: http.DefaultTransport,
tmpauth: t,
})
}

t.miniClient = &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
Transport: transport,
Transport: PromiseRoundTripper{transport.RoundTrip},
}

return t, nil
Expand Down Expand Up @@ -156,6 +156,14 @@ func (t *Tmpauth) ReauthMini() error {
return nil
}

type PromiseRoundTripper struct {
roundTrip func(*http.Request) (*http.Response, error)
}

func (p PromiseRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
return p.RoundTrip(req)
}

type MiniTransport struct {
http.RoundTripper
tmpauth *Tmpauth
Expand Down

0 comments on commit decc88e

Please sign in to comment.