MCPcopy Index your code
hub / github.com/SpectoLabs/hoverfly / SetScript

Method SetScript

core/middleware/middleware.go:46–66  ·  view source on GitHub ↗
(scriptContent string)

Source from the content-addressed store, hash-verified

44}
45
46func (this *Middleware) SetScript(scriptContent string) error {
47 tempDir := path.Join(os.TempDir(), "hoverfly")
48
49 //We ignore the error it outputs as this directory may already exist
50 os.Mkdir(tempDir, 0777)
51
52 newScript, err := os.CreateTemp(tempDir, "hoverfly_")
53 if err != nil {
54 return err
55 }
56
57 _, err = newScript.Write([]byte(scriptContent))
58 if err != nil {
59 return err
60 }
61
62 // remove existing script once the new one is created
63 this.DeleteScript()
64 this.Script = newScript
65 return nil
66}
67
68func (this Middleware) GetScript() (string, error) {
69 if this.Script == nil {

Calls 1

DeleteScriptMethod · 0.95