Explorar el Código

Improve the help page a bit

Lu Stadler %!s(int64=7) %!d(string=hace) años
padre
commit
efadb657d9
Se han modificado 1 ficheros con 9 adiciones y 6 borrados
  1. 9 6
      go/fake-http/fake-http.go

+ 9 - 6
go/fake-http/fake-http.go

118
	})
118
	})
119
119
120
	http.HandleFunc("/_help", func(w http.ResponseWriter, req *http.Request) {
120
	http.HandleFunc("/_help", func(w http.ResponseWriter, req *http.Request) {
121
		urls := []string{
122
			"/_log",
123
			"/_stub",
124
			"/_stubs",
125
			"/_help",
121
		urls := []struct {
122
			URL     string
123
			Summary string
124
		}{
125
			{URL: "/_log", Summary: "View all received requests with responses"},
126
			{URL: "/_stub", Summary: "Add a new response stub"},
127
			{URL: "/_stubs", Summary: "View all defined stubs"},
128
			{URL: "/_help", Summary: "This help"},
126
		}
129
		}
127
		fmt.Fprint(w, `<!doctype html>
130
		fmt.Fprint(w, `<!doctype html>
128
<html>
131
<html>
132
	<body>
135
	<body>
133
		<ul>`)
136
		<ul>`)
134
		for _, url := range urls {
137
		for _, url := range urls {
135
			fmt.Fprintf(w, "<li><pre><a href=\"%s\">%s</a></pre></li>", url, url)
138
			fmt.Fprintf(w, "<li><pre><a href=\"%s\">%s</a> - %s</pre></li>", url.URL, url.URL, url.Summary)
136
		}
139
		}
137
		fmt.Fprint(w, `
140
		fmt.Fprint(w, `
138
		</ul>
141
		</ul>