Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "io"
- "net/http"
- )
- type myHandler int
- func (h myHandler) ServeHTTP(res http.ResponseWriter, req *http.Request) {
- res.Header().Set("Content-Type", "text/html; charset=utf-8")
- switch req.URL.Path {
- case "/cat":
- io.WriteString(res, `<img src="https://upload.wikimedia.org/wikipedia/commons/0/06/Kitten_in_Rizal_Park%2C_Manila.jpg">`)
- case "/dog":
- io.WriteString(res, `<img src="https://upload.wikimedia.org/wikipedia/commons/6/6e/Golde33443.jpg">`)
- }
- }
- func main() {
- var h myHandler
- http.ListenAndServe(":9000", h)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement