Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.56 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "io"
  5.     "net/http"
  6. )
  7.  
  8. type myHandler int
  9.  
  10. func (h myHandler) ServeHTTP(res http.ResponseWriter, req *http.Request) {
  11.     res.Header().Set("Content-Type", "text/html; charset=utf-8")
  12.     switch req.URL.Path {
  13.     case "/cat":
  14.         io.WriteString(res, `<img src="https://upload.wikimedia.org/wikipedia/commons/0/06/Kitten_in_Rizal_Park%2C_Manila.jpg">`)
  15.     case "/dog":
  16.         io.WriteString(res, `<img src="https://upload.wikimedia.org/wikipedia/commons/6/6e/Golde33443.jpg">`)
  17.     }
  18. }
  19.  
  20. func main() {
  21.  
  22.     var h myHandler
  23.     http.ListenAndServe(":9000", h)
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement