@@ -34,7 +34,7 @@ type Proxy struct {
34
34
UserData interface {}
35
35
36
36
// Error handler.
37
- OnError func (ctx *Context, when string , err *Error, opErr error )
37
+ OnError func (ctx *Context, where string , err *Error, opErr error )
38
38
39
39
// Accept handler. It greets proxy request like ServeHTTP function of
40
40
// http.Handler.
@@ -43,7 +43,7 @@ type Proxy struct {
43
43
44
44
// Auth handler. If you need authentication, set this handler.
45
45
// If it returns true, authentication succeeded.
46
- OnAuth func (ctx *Context, user string , pass string ) bool
46
+ OnAuth func (ctx *Context, authType string , user string , pass string ) bool
47
47
48
48
// Connect handler. It sets connect action and new host.
49
49
// If len(newhost) > 0, host changes.
@@ -83,14 +83,18 @@ type Context struct {
83
83
// Sub session number of processing remote connection.
84
84
SubSessionNo int64
85
85
86
- // Action of after the CONNECT, if proxy request method is CONNECT .
86
+ // Original Proxy request.
87
87
// It's using internally. Don't change in Context struct!
88
- ConnectAction ConnectAction
88
+ Req *http. Request
89
89
90
- // Proxy request, if proxy request method is CONNECT.
90
+ // Original Proxy request, if proxy request method is CONNECT.
91
91
// It's using internally. Don't change in Context struct!
92
92
ConnectReq *http.Request
93
93
94
+ // Action of after the CONNECT, if proxy request method is CONNECT.
95
+ // It's using internally. Don't change in Context struct!
96
+ ConnectAction ConnectAction
97
+
94
98
// Remote host, if proxy request method is CONNECT.
95
99
// It's using internally. Don't change in Context struct!
96
100
ConnectHost string
@@ -100,7 +104,7 @@ type Context struct {
100
104
}
101
105
```
102
106
103
- ### Demo code
107
+ ### Simple code
104
108
105
109
``` go
106
110
package main
@@ -112,10 +116,10 @@ import (
112
116
" github.com/go-httpproxy/httpproxy"
113
117
)
114
118
115
- func OnError (ctx *httpproxy.Context , when string ,
119
+ func OnError (ctx *httpproxy.Context , where string ,
116
120
err *httpproxy.Error , opErr error ) {
117
121
// Log errors.
118
- log.Printf (" ERR: %s : %s [%s ]" , when , err, opErr)
122
+ log.Printf (" ERR: %s : %s [%s ]" , where , err, opErr)
119
123
}
120
124
121
125
func OnAccept (ctx *httpproxy.Context , w http.ResponseWriter ,
@@ -128,7 +132,7 @@ func OnAccept(ctx *httpproxy.Context, w http.ResponseWriter,
128
132
return false
129
133
}
130
134
131
- func OnAuth (ctx *httpproxy .Context , user string , pass string ) bool {
135
+ func OnAuth (ctx *httpproxy .Context , authType string , user string , pass string ) bool {
132
136
// Auth test user.
133
137
if user == " test" && pass == " 1234" {
134
138
return true
0 commit comments