Skip to content

Commit 36fa4dc

Browse files
authored
Merge pull request #13 from syumai/use-tinyutil
use tinyutil in basic-auth-proxy example
2 parents 6d7bee9 + 8c484c7 commit 36fa4dc

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

examples/basic-auth-proxy/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# basic-auth-proxy
22

3-
**Currently, not working**
4-
53
* This is an example of an HTTP proxy server with Basic-Auth .
64
* This proxy server adds Basic-Auth to `https://syum.ai` .
75

examples/basic-auth-proxy/go.mod

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ module github.com/syumai/basic-auth-server
22

33
go 1.18
44

5-
require github.com/syumai/workers v0.0.0
5+
require (
6+
github.com/syumai/tinyutil v0.1.0
7+
github.com/syumai/workers v0.0.0
8+
)
69

7-
replace github.com/syumai/workers => ../../
10+
replace github.com/syumai/workers => ../../

examples/basic-auth-proxy/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
github.com/syumai/workers v0.1.0 h1:z5QfQR2X+PCKzom7RodpI5J4D5YF7NT7Qwzb9AM9dgY=
2-
github.com/syumai/workers v0.1.0/go.mod h1:alXIDhTyeTwSzh0ZgQ3cb9HQPyyYfIejupE4Z3efr14=
1+
github.com/syumai/tinyutil v0.1.0 h1:XJeMlJqKMwhHhTFXg7qqdF+kGxDul//kkBKtMJlXm80=
2+
github.com/syumai/tinyutil v0.1.0/go.mod h1:/owCyUs1bh6tKxH7K1Ze3M/zZtZ+vGrj3h82fgNHDFI=

examples/basic-auth-proxy/main.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"log"
66
"net/http"
77

8+
"github.com/syumai/tinyutil/httputil"
89
"github.com/syumai/workers"
910
)
1011

@@ -32,13 +33,7 @@ func handleRequest(w http.ResponseWriter, req *http.Request) {
3233
u := *req.URL
3334
u.Scheme = "https"
3435
u.Host = "syum.ai"
35-
proxyReq, err := http.NewRequest("GET", u.String(), nil)
36-
if err != nil {
37-
handleError(w, http.StatusInternalServerError, "Internal Error")
38-
log.Printf("failed to create proxy request: %v\n", err)
39-
return
40-
}
41-
resp, err := (*Transport).RoundTrip(nil, proxyReq)
36+
resp, err := httputil.Get(u.String())
4237
if err != nil {
4338
handleError(w, http.StatusInternalServerError, "Internal Error")
4439
log.Printf("failed to execute proxy request: %v\n", err)

0 commit comments

Comments
 (0)