First of all, I created an HTML file using Notepad ++ with this code:
<body>
<table>
<tr>
<td>Jill</td>
<td>Smith</td>
<td><img src="images/test.jpg" border=3 height=100 width=300 /></td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
</body>
When I open this file it works fine, it shows me the table and the image inside the cell.
Then, in my Go Project inside Eclipse I created an HTML file with the same code and try to run but it didn't work, it didn't show the image.
So, I tried to put the image in the same folder as the HTML file and didn't work again.
Both are in the folder: tmpl
<body>
<table>
<tr>
<td>Jill</td>
<td>Smith</td>
<td><img src="test.jpg" border=3 height=100 width=300 /></td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
</body>
Problem:
rootHandler: Could not forward request for /tmpl/teste.jpg any further.
Go Code:
// * /
func rootHandler(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
homeHandler(w, r)
} else {
log.Printf("rootHandler: Could not forward request for %s any further.", r.RequestURI)
errNotFound(w, r)
}
}
Add a FileServer to the project:
m.Handle("/images/", http.StripPrefix("/images/", http.FileServer(http.Dir("images/"))))