Skip to content

Commit

Permalink
Merge pull request #26 from SpectoLabs/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Karolis Rusenas committed Dec 10, 2015
2 parents df1caf5 + 7247ad4 commit d2893f7
Show file tree
Hide file tree
Showing 19 changed files with 1,291 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ _test
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
/vendor
_cgo_export.*

_testmain.go
Expand All @@ -31,3 +30,4 @@ hoverfly

# examples/clients/readthedocs_query/test.py pickle file
links.p
static/js/node_modules
18 changes: 18 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[submodule "redigo"]
path = vendor/github.com/garyburd/redigo
url = https://github.com/garyburd/redigo
[submodule "logrus"]
path = vendor/github.com/Sirupsen/logrus
url = https://github.com/Sirupsen/logrus
[submodule "goproxy"]
path = vendor/github.com/elazarl/goproxy
url = https://github.com/elazarl/goproxy
[submodule "negroni-logrus"]
path = vendor/github.com/meatballhat/negroni-logrus
url = https://github.com/meatballhat/negroni-logrus
[submodule "negroni"]
path = vendor/github.com/codegangsta/negroni
url = https://github.com/codegangsta/negroni
[submodule "bone"]
path = vendor/github.com/go-zoo/bone
url = https://github.com/go-zoo/bone
22 changes: 21 additions & 1 deletion admin.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package main

import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"

"encoding/json"
log "github.com/Sirupsen/logrus"
"github.com/codegangsta/negroni"
"github.com/go-zoo/bone"
"github.com/meatballhat/negroni-logrus"
)

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

func (d *DBClient) startAdminInterface() {
// starting admin interface
mux := getBoneRouter(*d)
n := negroni.Classic()
n.Use(negronilogrus.NewMiddleware())
n.UseHandler(mux)

// admin interface starting message
log.WithFields(log.Fields{
"RedisAddress": AppConfig.redisAddress,
"AdminPort": AppConfig.adminInterface,
}).Info("Admin interface is starting...")

n.Run(AppConfig.adminInterface)
}

// getBoneRouter returns mux for admin interface
func getBoneRouter(d DBClient) *bone.Mux {
mux := bone.New()
Expand All @@ -35,6 +53,8 @@ func getBoneRouter(d DBClient) *bone.Mux {
mux.Get("/state", http.HandlerFunc(d.CurrentStateHandler))
mux.Post("/state", http.HandlerFunc(d.stateHandler))

mux.Handle("/*", http.FileServer(http.Dir("static")))

return mux
}

Expand Down
18 changes: 0 additions & 18 deletions hoverfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package main

import (
log "github.com/Sirupsen/logrus"
"github.com/codegangsta/negroni"
"github.com/elazarl/goproxy"
"github.com/meatballhat/negroni-logrus"

"bufio"
"flag"
Expand Down Expand Up @@ -211,19 +209,3 @@ func (d *DBClient) processRequest(req *http.Request) (*http.Request, *http.Respo

}
}

func (d *DBClient) startAdminInterface() {
// starting admin interface
mux := getBoneRouter(*d)
n := negroni.Classic()
n.Use(negronilogrus.NewMiddleware())
n.UseHandler(mux)

// admin interface starting message
log.WithFields(log.Fields{
"RedisAddress": AppConfig.redisAddress,
"AdminPort": AppConfig.adminInterface,
}).Info("Admin interface is starting...")

n.Run(AppConfig.adminInterface)
}
7 changes: 6 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Then, build it:
Run it:
* ./hoverfly


## Destination configuration

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

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

## Administrator web UI

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

## API

Access administrator API under default port 8888:
Expand Down
Loading

0 comments on commit d2893f7

Please sign in to comment.