Home | History | Annotate | Download | only in wiki
      1 *** final.go	2015-06-14 23:59:22.000000000 +0200
      2 --- final-test.go	2015-06-15 00:15:41.000000000 +0200
      3 ***************
      4 *** 7,12 ****
      5 --- 7,14 ----
      6   import (
      7   	"html/template"
      8   	"io/ioutil"
      9 + 	"log"
     10 + 	"net"
     11   	"net/http"
     12   	"regexp"
     13   )
     14 ***************
     15 *** 85,89 ****
     16   	http.HandleFunc("/edit/", makeHandler(editHandler))
     17   	http.HandleFunc("/save/", makeHandler(saveHandler))
     18   
     19 ! 	http.ListenAndServe(":8080", nil)
     20   }
     21 --- 87,101 ----
     22   	http.HandleFunc("/edit/", makeHandler(editHandler))
     23   	http.HandleFunc("/save/", makeHandler(saveHandler))
     24   
     25 ! 	l, err := net.Listen("tcp", "127.0.0.1:0")
     26 ! 	if err != nil {
     27 ! 		log.Fatal(err)
     28 ! 	}
     29 ! 	err = ioutil.WriteFile("final-test-port.txt", []byte(l.Addr().String()), 0644)
     30 ! 	if err != nil {
     31 ! 		log.Fatal(err)
     32 ! 	}
     33 ! 	s := &http.Server{}
     34 ! 	s.Serve(l)
     35 ! 	return
     36   }
     37