hnakra/examples/image/main.go

23 lines
671 B
Go
Raw Normal View History

2023-05-25 16:08:56 -06:00
package main
import "log"
import "net/http"
import "hnakra/service"
func main () {
http.HandleFunc("/fractal.png", func (res http.ResponseWriter, req *http.Request) {
// An interesting quirk relating to http.ServeFile: there needs
// to be a one-to-one correspondance between pattern path and
// file. This means you can't serve an image on a rooted
// subtree. Otherwise it will randomly fail. I think this has to
// do with how *something* is caching the file.
http.ServeFile(res, req, "fractal.png")
})
err := service.NewHTTP (
"Image",
"Displays an image of a fractal.",
"@", "/fractal.png").Run()
2023-05-25 16:08:56 -06:00
if err != nil { log.Println("XXX", err) }
}