MCPcopy Create free account
hub / github.com/cheikhshift/cleo / Netserver

Function Netserver

application.go:1199–1244  ·  view source on GitHub ↗
(args ...interface{})

Source from the content-addressed store, hash-verified

1197var templateIDserver = "tmpl/momentum/server.tmpl"
1198
1199func Netserver(args ...interface{}) string {
1200
1201 localid := templateIDserver
1202 var d *gosweb.NoStruct
1203 defer templateFNserver(localid, d)
1204 if len(args) > 0 {
1205 jso := args[0].(string)
1206 var jsonBlob = []byte(jso)
1207 err := json.Unmarshal(jsonBlob, d)
1208 if err != nil {
1209 return err.Error()
1210 }
1211 } else {
1212 d = &gosweb.NoStruct{}
1213 }
1214
1215 output := new(bytes.Buffer)
1216
1217 if _, ok := templateCache.Get(localid); !ok || !Prod {
1218
1219 body, er := Asset(localid)
1220 if er != nil {
1221 return ""
1222 }
1223 var localtemplate = template.New("server")
1224 localtemplate.Funcs(TemplateFuncStore)
1225 var tmpstr = string(body)
1226 localtemplate.Parse(tmpstr)
1227 body = nil
1228 templateCache.Put(localid, localtemplate)
1229 }
1230
1231 erro := templateCache.JGet(localid).Execute(output, d)
1232 if erro != nil {
1233 color.Red(fmt.Sprintf("Error processing template %s", localid))
1234 DebugTemplatePath(localid, d)
1235 }
1236 var outps = output.String()
1237 var outpescaped = html.UnescapeString(outps)
1238 d = nil
1239 output.Reset()
1240 output = nil
1241 args = nil
1242 return outpescaped
1243
1244}
1245func bserver(d gosweb.NoStruct) string {
1246 return Netbserver(d)
1247}

Callers 1

mainFunction · 0.85

Calls 3

templateFNserverFunction · 0.85
AssetFunction · 0.85
DebugTemplatePathFunction · 0.85

Tested by

no test coverage detected