diff options
Diffstat (limited to 'phlox/main.go')
-rw-r--r-- | phlox/main.go | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/phlox/main.go b/phlox/main.go index 3516374..ee9416c 100644 --- a/phlox/main.go +++ b/phlox/main.go @@ -4,14 +4,30 @@ import ( "fmt" "io" "strings" + "flag" "net" "net/http" "net/url" log "github.com/sirupsen/logrus" + db "sanine.net/git/phlox/db" ) +var p *db.Plhox + + func main() { + var dbfile string + flag.StringVar(&dbfile, "db", "/etc/phlox/phlox.conf", "path to the configuration db") + flag.Parse() + + p := &db.Phlox{} + err := p.Open(dbfile) + if err != nil { + log.Fatal(err) + } + defer p.Close() + const addr = "localhost:3333" log.Info("configuring reverse proxy...") @@ -22,12 +38,6 @@ func main() { } -type Endpoint struct { - Path string - Origin *url.URL -} - - func configureEndpoint(path, address string) { log.Infof("proxying endpoint %v to %v", path, address) origin, err := url.Parse(address) @@ -68,7 +78,7 @@ func proxyRequest(w http.ResponseWriter, req *http.Request, end Endpoint) *http // misc request cleanups req.URL.Scheme = end.Origin.Scheme req.RequestURI = "" - + // make request response, err := http.DefaultClient.Do(req) if err != nil { |