summaryrefslogtreecommitdiff
path: root/phlox/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'phlox/main.go')
-rw-r--r--phlox/main.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/phlox/main.go b/phlox/main.go
index ee9416c..3f80724 100644
--- a/phlox/main.go
+++ b/phlox/main.go
@@ -13,7 +13,7 @@ import (
)
-var p *db.Plhox
+var p *db.Phlox
func main() {
@@ -28,16 +28,31 @@ func main() {
}
defer p.Close()
- const addr = "localhost:3333"
+ addr, err := p.GetHostAddress()
+ if err != nil {
+ log.Fatal(err)
+ }
+ endpoints, err := p.AllEndpoints()
+ if err != nil {
+ log.Fatal(err)
+ }
log.Info("configuring reverse proxy...")
- configureEndpoint("/proxy1", "http://localhost:8000")
+ for _, endpoint := range endpoints {
+ configureEndpoint(endpoint.Path, endpoint.Address)
+ }
log.Infof("serving on %v", addr)
log.Fatal(http.ListenAndServe(addr, nil))
}
+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)