-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (32 loc) · 827 Bytes
/
main.go
File metadata and controls
39 lines (32 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"aws-proxy/proxy"
"context"
"flag"
"fmt"
"github.com/aws/aws-sdk-go-v2/config"
"log"
"net/http"
"time"
)
func main() {
port := flag.Int("port", 8080, "port to run proxy on")
debug := flag.Bool("verbose", false, "enable debug logs")
partition := flag.String("aws-partition", "aws", "aws partition to use")
flag.Parse()
addr := fmt.Sprintf("0.0.0.0:%d", *port)
cfg, err := config.LoadDefaultConfig(context.TODO(),
config.WithEndpointResolver(defaultEndpointResolver(*partition)),
)
if err != nil {
panic(err)
}
handler := proxy.NewProxyHandler(http.DefaultClient, &cfg, *debug)
server := http.Server{
Addr: addr,
Handler: handler,
ReadHeaderTimeout: 60 * time.Second,
}
fmt.Printf("Listening on %s\n", addr)
log.Panic(server.ListenAndServe())
}