-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (38 loc) · 1006 Bytes
/
main.go
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
40
41
42
43
44
45
46
47
48
package main
import (
"fmt"
"github.com/Banyango/Alligator/config"
"github.com/Banyango/Alligator/reverseProxy"
"github.com/labstack/gommon/log"
"io/ioutil"
"net/http"
"os"
)
const banner = `
_____ .__ .__ .__ __
/ _ \ | | | | |__| _________ _/ |_ ___________
/ /_\ \| | | | | |/ ___\__ \\ __\/ _ \_ __ \
/ | \ |_| |_| / /_/ > __ \| | ( <_> ) | \/
\____|__ /____/____/__\___ (____ /__| \____/|__|
\/ /_____/ \/
`
func main() {
fmt.Println(banner)
addr, hasPort := os.LookupEnv("addr")
if !hasPort {
addr = ":8080"
}
fmt.Println("Reverse Proxy Starting up at", addr)
tomlBytes, err := ioutil.ReadFile("./alligator.toml")
if err != nil {
log.Fatal(err)
}
conf, err := config.New(string(tomlBytes))
if err != nil {
log.Fatal(err)
}
handler := reverseProxy.New(*conf)
if err := http.ListenAndServe(addr, handler.Build()); err != nil {
log.Fatal(err)
}
}