@@ -25,6 +25,7 @@ import (
2525 "flag"
2626 "fmt"
2727 "io"
28+ "io/ioutil"
2829 "os"
2930 "strings"
3031 "time"
@@ -117,6 +118,8 @@ var (
117118 cors = flag .Bool ("cors" , false , "Enable CORS support" )
118119 noImportCheck = flag .Bool ("no-import-check" , false , "Skip duplicate request check when importing simulations" )
119120
121+ pacFile = flag .String ("pac-file" , "" , "Path to the pac file to be imported on startup" )
122+
120123 clientAuthenticationDestination = flag .String ("client-authentication-destination" , "" , "Regular expression of destination with client authentication" )
121124 clientAuthenticationClientCert = flag .String ("client-authentication-client-cert" , "" , "Path to the client certification file used for authentication" )
122125 clientAuthenticationClientKey = flag .String ("client-authentication-client-key" , "" , "Path to the client key file used for authentication" )
@@ -568,6 +571,17 @@ func main() {
568571
569572 cfg .Webserver = * webserver
570573
574+ if * pacFile != "" {
575+ pacFileContent , err := ioutil .ReadFile (* pacFile )
576+ if err != nil {
577+ log .WithFields (log.Fields {"error" : err .Error (), "pacFile" : * pacFile }).
578+ Fatal ("Failed to import pac file" )
579+ }
580+
581+ log .WithField ("pacFile" , * pacFile ).Infoln ("Using provided pac file" )
582+ hoverfly .SetPACFile (pacFileContent )
583+ }
584+
571585 err = hoverfly .StartProxy ()
572586 if err != nil {
573587 log .WithFields (log.Fields {
0 commit comments