@@ -16,6 +16,7 @@ type HoverflyMiddleware interface {
1616
1717type HoverflyMiddlewareHandler struct {
1818 Hoverfly HoverflyMiddleware
19+ Enabled bool
1920}
2021
2122func (this * HoverflyMiddlewareHandler ) RegisterRoutes (mux * bone.Mux , am * handlers.AuthHandler ) {
@@ -24,10 +25,12 @@ func (this *HoverflyMiddlewareHandler) RegisterRoutes(mux *bone.Mux, am *handler
2425 negroni .HandlerFunc (this .Get ),
2526 ))
2627
27- mux .Put ("/api/v2/hoverfly/middleware" , negroni .New (
28- negroni .HandlerFunc (am .RequireTokenAuthentication ),
29- negroni .HandlerFunc (this .Put ),
30- ))
28+ if this .Enabled {
29+ mux .Put ("/api/v2/hoverfly/middleware" , negroni .New (
30+ negroni .HandlerFunc (am .RequireTokenAuthentication ),
31+ negroni .HandlerFunc (this .Put ),
32+ ))
33+ }
3134 mux .Options ("/api/v2/hoverfly/middleware" , negroni .New (
3235 negroni .HandlerFunc (this .Options ),
3336 ))
@@ -60,6 +63,10 @@ func (this *HoverflyMiddlewareHandler) Put(w http.ResponseWriter, req *http.Requ
6063}
6164
6265func (this * HoverflyMiddlewareHandler ) Options (w http.ResponseWriter , r * http.Request , next http.HandlerFunc ) {
63- w .Header ().Add ("Allow" , "OPTIONS, GET, PUT" )
66+ allow := "OPTIONS, GET"
67+ if this .Enabled {
68+ allow += ", PUT"
69+ }
70+ w .Header ().Add ("Allow" , allow )
6471 handlers .WriteResponse (w , []byte ("" ))
6572}
0 commit comments