Skip to content

Commit 603876c

Browse files
committed
Adding configuration endpoint
1 parent 7110f39 commit 603876c

File tree

6 files changed

+53
-3
lines changed

6 files changed

+53
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ _testmain.go
2424
*.prof
2525

2626
proxy_linux_*
27+
proxy.log

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 0.5.0
2+
3+
* [@KensoDev] - 2015/06/30 - Added a complete docker workflow
4+
* `/proxy/configuration` will now respond with the configuration JSON so you
5+
can view the config and make sure it's right.
6+
* Refactoring
7+
8+
19
## 0.2.0
210

311
* [@KensoDev] - 2015/06/29 - Added the `BucketPrefix` to `AWSConfig`.

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ Flags:
8686
8787
```
8888

89+
### View configuration when running
90+
91+
When the proxy is running it has a web-accesible configuration JSON.
92+
You can access it by going to `/proxy/configuration`.
93+
94+
It looks like this:
95+
96+
![Proxy Configuration](http://aviioblog.s3.amazonaws.com/screen-shot-2015-06-30-i4isg.png)
97+
98+
## CHANGELOG
99+
100+
[View Here](CHANGELOG.md)
101+
102+
89103
## Status
90104

91105
This is under active development at [Gogobot](http://gogobot.com).

cmd/proxy/proxy

144 Bytes
Binary file not shown.

cmd/proxy/solr_proxy.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ func main() {
3535
},
3636
}
3737

38-
fmt.Printf("You have %d slaves\n", len(slaveServers))
38+
config := proxy.NewConfigurationRender(proxyConfig)
39+
http.Handle("/proxy/configuration", config)
3940

4041
p := proxy.NewProxy(proxyConfig)
4142
http.Handle("/", p)
4243

43-
fmt.Printf("Starting proxy on port %d\n", *listenPort)
44-
4544
if err := http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", *listenPort), nil); err != nil {
4645
panic(err)
4746
}

configuration.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package proxy
2+
3+
import (
4+
"encoding/json"
5+
"net/http"
6+
)
7+
8+
type Configuration struct {
9+
proxyconfig *ProxyConfig
10+
}
11+
12+
func (c *Configuration) ServeHTTP(w http.ResponseWriter, req *http.Request) {
13+
json, err := json.Marshal(c.proxyconfig)
14+
15+
if err != nil {
16+
http.Error(w, err.Error(), http.StatusInternalServerError)
17+
}
18+
19+
w.Header().Set("Content-Type", "application/json")
20+
w.Write(json)
21+
}
22+
23+
func NewConfigurationRender(proxyConfig *ProxyConfig) (config *Configuration) {
24+
config = &Configuration{
25+
proxyconfig: proxyConfig,
26+
}
27+
return
28+
}

0 commit comments

Comments
 (0)