headerServer is a simple HTTP server that displays the passed headers in the html.
(addr string)
| 43 | |
| 44 | // headerServer is a simple HTTP server that displays the passed headers in the html. |
| 45 | func headerServer(addr string) error { |
| 46 | mux := http.NewServeMux() |
| 47 | mux.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) { |
| 48 | buf, err := json.MarshalIndent(req.Header, "", " ") |
| 49 | if err != nil { |
| 50 | http.Error(res, err.Error(), http.StatusInternalServerError) |
| 51 | return |
| 52 | } |
| 53 | fmt.Fprintf(res, indexHTML, string(buf)) |
| 54 | }) |
| 55 | return http.ListenAndServe(addr, mux) |
| 56 | } |
| 57 | |
| 58 | // setheaders returns a task list that sets the passed headers. |
| 59 | func setheaders(host string, headers map[string]interface{}, res *string) chromedp.Tasks { |