Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. //.....code.....
  2. if bol {
  3. // Assignment Struct.Var
  4. Struct_VastScript.TxtNoticeTop = JsonStruct_S.Options.TxtNoticeTop
  5. Struct_VastScript.TxtNoticeBottom = JsonStruct_S.Options.TxtNoticeBottom
  6. Struct_VastScript.Loop = JsonStruct_S.Options.Loop
  7.  
  8. Struct_Image, err := getImage(Struct_VastScript.Video)
  9. if err == nil {
  10. if mobile == "true" {
  11. Struct_VastScript.Image = Struct_Image.URL360
  12. }
  13. }
  14. //open and parse a template file
  15. fi = path.Join("templates/VastPlayer", "TempVastPlayer.txt")
  16. tmpl, err := template.ParseFiles(fi)
  17.  
  18. if err != nil {
  19. job_1.Complete(health.Panic)
  20. return false, err
  21. }
  22. //substitute fields in the template 'tmpl', with values from 'XmlStruct_V' and write it out to 'buf'
  23. var buf bytes.Buffer
  24. if err := tmpl.Execute(&buf, Struct_VastScript); err != nil {
  25. //if err := tmpl.Execute(w, XmlStruct_V); err != nil {
  26. job_1.Complete(health.Panic)
  27. return false, err
  28. }
  29.  
  30. // Call Func randString() : return alphanum random
  31. dir := randString(12)
  32. fpath := "http://creative2.xxx.io/api/html/" + dir
  33.  
  34. // Create a new EndPoint to write the generated 'template' on 'w' http.ResponseWriter
  35. routeHtml := "/api/html/" + dir
  36. http.HandleFunc(routeHtml, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  37. //writes Template to 'w' http.ResponseWriter
  38. fmt.Fprintf(w, buf.String())
  39. fmt.Println("successfull Operation 2 !!")
  40. fmt.Println("")
  41. job_2.Complete(health.Success)
  42. }))
  43.  
  44.  
  45. //Call Func JsonReply(): return the finale Json response
  46. 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)
  47. w.Header().Set("Content-Type", "application/json")
  48. //writes FinaleJson to 'w' http.ResponseWriter(it contains the link of the second endpoint "/api/html/")
  49. fmt.Fprint(w, str)
  50. fmt.Println("successfull Operation !!")
  51. fmt.Println("")
  52. job_1.Complete(health.Success)
  53. return true, nil
  54. } else {
  55. return false, nil
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement