Skip to content

Commit 56cce93

Browse files
Merge pull request #4 from go-httpproxy/develop
v1.3
2 parents 7a6ed94 + 9449c44 commit 56cce93

File tree

13 files changed

+885
-678
lines changed

13 files changed

+885
-678
lines changed

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type Proxy struct {
3434
UserData interface{}
3535

3636
// Error handler.
37-
OnError func(ctx *Context, when string, err *Error, opErr error)
37+
OnError func(ctx *Context, where string, err *Error, opErr error)
3838

3939
// Accept handler. It greets proxy request like ServeHTTP function of
4040
// http.Handler.
@@ -43,7 +43,7 @@ type Proxy struct {
4343

4444
// Auth handler. If you need authentication, set this handler.
4545
// 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
4747

4848
// Connect handler. It sets connect action and new host.
4949
// If len(newhost) > 0, host changes.
@@ -83,14 +83,18 @@ type Context struct {
8383
// Sub session number of processing remote connection.
8484
SubSessionNo int64
8585

86-
// Action of after the CONNECT, if proxy request method is CONNECT.
86+
// Original Proxy request.
8787
// It's using internally. Don't change in Context struct!
88-
ConnectAction ConnectAction
88+
Req *http.Request
8989

90-
// Proxy request, if proxy request method is CONNECT.
90+
// Original Proxy request, if proxy request method is CONNECT.
9191
// It's using internally. Don't change in Context struct!
9292
ConnectReq *http.Request
9393

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+
9498
// Remote host, if proxy request method is CONNECT.
9599
// It's using internally. Don't change in Context struct!
96100
ConnectHost string
@@ -100,7 +104,7 @@ type Context struct {
100104
}
101105
```
102106

103-
### Demo code
107+
### Simple code
104108

105109
```go
106110
package main
@@ -112,10 +116,10 @@ import (
112116
"github.com/go-httpproxy/httpproxy"
113117
)
114118

115-
func OnError(ctx *httpproxy.Context, when string,
119+
func OnError(ctx *httpproxy.Context, where string,
116120
err *httpproxy.Error, opErr error) {
117121
// Log errors.
118-
log.Printf("ERR: %s: %s [%s]", when, err, opErr)
122+
log.Printf("ERR: %s: %s [%s]", where, err, opErr)
119123
}
120124

121125
func OnAccept(ctx *httpproxy.Context, w http.ResponseWriter,
@@ -128,7 +132,7 @@ func OnAccept(ctx *httpproxy.Context, w http.ResponseWriter,
128132
return false
129133
}
130134

131-
func OnAuth(ctx *httpproxy.Context, user string, pass string) bool {
135+
func OnAuth(ctx *httpproxy.Context, authType string, user string, pass string) bool {
132136
// Auth test user.
133137
if user == "test" && pass == "1234" {
134138
return true

ca.go

Lines changed: 0 additions & 236 deletions
This file was deleted.

0 commit comments

Comments
 (0)