Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //.....code.....
- if bol {
- // Assignment Struct.Var
- Struct_VastScript.TxtNoticeTop = JsonStruct_S.Options.TxtNoticeTop
- Struct_VastScript.TxtNoticeBottom = JsonStruct_S.Options.TxtNoticeBottom
- Struct_VastScript.Loop = JsonStruct_S.Options.Loop
- Struct_Image, err := getImage(Struct_VastScript.Video)
- if err == nil {
- if mobile == "true" {
- Struct_VastScript.Image = Struct_Image.URL360
- }
- }
- //open and parse a template file
- fi = path.Join("templates/VastPlayer", "TempVastPlayer.txt")
- tmpl, err := template.ParseFiles(fi)
- if err != nil {
- job_1.Complete(health.Panic)
- return false, err
- }
- //substitute fields in the template 'tmpl', with values from 'XmlStruct_V' and write it out to 'buf'
- var buf bytes.Buffer
- if err := tmpl.Execute(&buf, Struct_VastScript); err != nil {
- //if err := tmpl.Execute(w, XmlStruct_V); err != nil {
- job_1.Complete(health.Panic)
- return false, err
- }
- // Call Func randString() : return alphanum random
- dir := randString(12)
- fpath := "http://creative2.xxx.io/api/html/" + dir
- // Create a new EndPoint to write the generated 'template' on 'w' http.ResponseWriter
- routeHtml := "/api/html/" + dir
- http.HandleFunc(routeHtml, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- //writes Template to 'w' http.ResponseWriter
- fmt.Fprintf(w, buf.String())
- fmt.Println("successfull Operation 2 !!")
- fmt.Println("")
- job_2.Complete(health.Success)
- }))
- //Call Func JsonReply(): return the finale Json response
- str := JsonReply(fpath, JsonStruct_S.Options.Animated, JsonStruct_S.Options.Responsive, JsonStruct_S.Options.Clickurl, JsonStruct_S.Options.Width, JsonStruct_S.Options.Height, adid, campaignid, JsonStruct_S.Type, JsonStruct_S.Options.Aspectratio, mobile)
- w.Header().Set("Content-Type", "application/json")
- //writes FinaleJson to 'w' http.ResponseWriter(it contains the link of the second endpoint "/api/html/")
- fmt.Fprint(w, str)
- fmt.Println("successfull Operation !!")
- fmt.Println("")
- job_1.Complete(health.Success)
- return true, nil
- } else {
- return false, nil
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement