Skip to content

Commit d2893f7

Browse files
author
Karolis Rusenas
committed
Merge pull request #26 from SpectoLabs/develop
Develop
2 parents df1caf5 + 7247ad4 commit d2893f7

File tree

19 files changed

+1291
-21
lines changed

19 files changed

+1291
-21
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ _test
1616
*.cgo2.c
1717
_cgo_defun.c
1818
_cgo_gotypes.go
19-
/vendor
2019
_cgo_export.*
2120

2221
_testmain.go
@@ -31,3 +30,4 @@ hoverfly
3130

3231
# examples/clients/readthedocs_query/test.py pickle file
3332
links.p
33+
static/js/node_modules

.gitmodules

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[submodule "redigo"]
2+
path = vendor/github.com/garyburd/redigo
3+
url = https://github.com/garyburd/redigo
4+
[submodule "logrus"]
5+
path = vendor/github.com/Sirupsen/logrus
6+
url = https://github.com/Sirupsen/logrus
7+
[submodule "goproxy"]
8+
path = vendor/github.com/elazarl/goproxy
9+
url = https://github.com/elazarl/goproxy
10+
[submodule "negroni-logrus"]
11+
path = vendor/github.com/meatballhat/negroni-logrus
12+
url = https://github.com/meatballhat/negroni-logrus
13+
[submodule "negroni"]
14+
path = vendor/github.com/codegangsta/negroni
15+
url = https://github.com/codegangsta/negroni
16+
[submodule "bone"]
17+
path = vendor/github.com/go-zoo/bone
18+
url = https://github.com/go-zoo/bone

admin.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package main
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"io/ioutil"
67
"net/http"
78

8-
"encoding/json"
99
log "github.com/Sirupsen/logrus"
10+
"github.com/codegangsta/negroni"
1011
"github.com/go-zoo/bone"
12+
"github.com/meatballhat/negroni-logrus"
1113
)
1214

1315
// jsonResponse struct encapsulates payload data
@@ -24,6 +26,22 @@ type messageResponse struct {
2426
Message string `json:"message"`
2527
}
2628

29+
func (d *DBClient) startAdminInterface() {
30+
// starting admin interface
31+
mux := getBoneRouter(*d)
32+
n := negroni.Classic()
33+
n.Use(negronilogrus.NewMiddleware())
34+
n.UseHandler(mux)
35+
36+
// admin interface starting message
37+
log.WithFields(log.Fields{
38+
"RedisAddress": AppConfig.redisAddress,
39+
"AdminPort": AppConfig.adminInterface,
40+
}).Info("Admin interface is starting...")
41+
42+
n.Run(AppConfig.adminInterface)
43+
}
44+
2745
// getBoneRouter returns mux for admin interface
2846
func getBoneRouter(d DBClient) *bone.Mux {
2947
mux := bone.New()
@@ -35,6 +53,8 @@ func getBoneRouter(d DBClient) *bone.Mux {
3553
mux.Get("/state", http.HandlerFunc(d.CurrentStateHandler))
3654
mux.Post("/state", http.HandlerFunc(d.stateHandler))
3755

56+
mux.Handle("/*", http.FileServer(http.Dir("static")))
57+
3858
return mux
3959
}
4060

hoverfly.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ package main
22

33
import (
44
log "github.com/Sirupsen/logrus"
5-
"github.com/codegangsta/negroni"
65
"github.com/elazarl/goproxy"
7-
"github.com/meatballhat/negroni-logrus"
86

97
"bufio"
108
"flag"
@@ -211,19 +209,3 @@ func (d *DBClient) processRequest(req *http.Request) (*http.Request, *http.Respo
211209

212210
}
213211
}
214-
215-
func (d *DBClient) startAdminInterface() {
216-
// starting admin interface
217-
mux := getBoneRouter(*d)
218-
n := negroni.Classic()
219-
n.Use(negronilogrus.NewMiddleware())
220-
n.UseHandler(mux)
221-
222-
// admin interface starting message
223-
log.WithFields(log.Fields{
224-
"RedisAddress": AppConfig.redisAddress,
225-
"AdminPort": AppConfig.adminInterface,
226-
}).Info("Admin interface is starting...")
227-
228-
n.Run(AppConfig.adminInterface)
229-
}

readme.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Then, build it:
1616
Run it:
1717
* ./hoverfly
1818

19-
2019
## Destination configuration
2120

2221
Specifying which site to record/virtualize with regular expression (by default it processes everything):
@@ -73,6 +72,12 @@ Add ca.pem to your trusted certificates or turn off verification, with curl you
7372

7473
curl https://www.bbc.co.uk --proxy http://localhost:8500 -k
7574

75+
## Administrator web UI
76+
77+
By default proxy launches admin API and UI on port 8888. Access admin interface for basic operations on http://proxy_hostname:8888/.
78+
It uses same API as described below to change state, also allows to wipe captured requests/responses and show current count of records.
79+
For other functions such as export/import - use API directly.
80+
7681
## API
7782

7883
Access administrator API under default port 8888:

0 commit comments

Comments
 (0)