Testing http handlers

I tried testing that my handlers responded with the correct html template, i achieved this by “stringing-fy”, the test seems to pass for this method. Here are my questions and problem;

  1. Is there any better devised way to do this?
  2. this method failed for the template i passed a dynamic data

template.Execute(a.html, passed-in-data)

What better way can this be done? Thank you.

Here is how I created a “static web site”

Hi @Oluwatobi_Giwa,

Can you share more details about your issue? Without the context, it is very hard to understand what you want to achieve or why your code fails.

  • What is “stringing-fy”? Why did you need this to make your handlers respond with the correct HTML template?
  • What does “this” refer to in “Is there any better devised way to do this?”
  • How does the Execute method fail? Especially:
    • What error message do you get?
    • Which template do you use?
    • Which data did you pass in?
    • Does the Execute method succeed for other kind of data or template? If so, how do the successful cases differ from the failing ones?

If possible, please share a minimal version of your code and data here, just enough code and data to replicate the problem. You can use the Go Playground to share executable code with the forum.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.