Ver Código Fonte

Render the file specified in the path

This supports navigating between links.  :)
Lu Stadler 7 anos atrás
pai
commit
a83ee6cedc
1 arquivos alterados com 1 adições e 1 exclusões
  1. 1 1
      go/tmpview/tmpview.go

+ 1 - 1
go/tmpview/tmpview.go

25
25
26
	if os.Args[1] == "serve" {
26
	if os.Args[1] == "serve" {
27
		addr := os.Args[2]
27
		addr := os.Args[2]
28
		fileName := os.Args[3]
29
28
30
		mux := http.NewServeMux()
29
		mux := http.NewServeMux()
31
		mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
30
		mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
32
			lastVisit = time.Now()
31
			lastVisit = time.Now()
33
32
33
			fileName := req.URL.Path[1:]
34
			data, err := ioutil.ReadFile(fileName)
34
			data, err := ioutil.ReadFile(fileName)
35
			if err != nil {
35
			if err != nil {
36
				http.Error(w, "could not read file", http.StatusNotFound)
36
				http.Error(w, "could not read file", http.StatusNotFound)