MCPcopy Create free account
hub / github.com/crossoverJie/gscript / httpRun

Function httpRun

internal_http.go:80–101  ·  view source on GitHub ↗
(v *Visitor, ctx *parser.FunctionCallContext)

Source from the content-addressed store, hash-verified

78}
79
80func httpRun(v *Visitor, ctx *parser.FunctionCallContext) interface{} {
81 paramValues := v.buildParamValues(ctx)
82 p0 := paramValues[0]
83 var addr string
84 switch p0.(type) {
85 case string:
86 addr = fmt.Sprintf("%s", p0)
87 }
88
89 if addr != "" {
90 ip := externalIP()
91 fmt.Println(fmt.Sprintf("http host %s on port%s", ip, addr))
92 err := http.ListenAndServe(addr, nil)
93 if err != nil {
94 log.RuntimePanic(ctx, fmt.Sprintf("httpRun function error occurred,error:%s", err))
95 }
96 } else {
97 log.RuntimePanic(ctx, fmt.Sprintf("addr cannot be empty"))
98 }
99
100 return nil
101}
102
103func fprintfJSON(v *Visitor, ctx *parser.FunctionCallContext) interface{} {
104 paramValues := v.buildParamValues(ctx)

Callers

nothing calls this directly

Calls 3

RuntimePanicFunction · 0.92
externalIPFunction · 0.85
buildParamValuesMethod · 0.80

Tested by

no test coverage detected