diff options
Diffstat (limited to 'ipn')
| -rw-r--r-- | ipn/ipn_clone.go | 6 | ||||
| -rw-r--r-- | ipn/ipn_view.go | 10 | ||||
| -rw-r--r-- | ipn/ipnlocal/serve.go | 4 | ||||
| -rw-r--r-- | ipn/serve.go | 2 |
4 files changed, 16 insertions, 6 deletions
diff --git a/ipn/ipn_clone.go b/ipn/ipn_clone.go index 8971b7b90..d0ae68069 100644 --- a/ipn/ipn_clone.go +++ b/ipn/ipn_clone.go @@ -118,6 +118,10 @@ func (src *HTTPHandler) Clone() *HTTPHandler { } dst := new(HTTPHandler) *dst = *src + if dst.Text != nil { + dst.Text = new(string) + *dst.Text = *src.Text + } return dst } @@ -125,7 +129,7 @@ func (src *HTTPHandler) Clone() *HTTPHandler { var _HTTPHandlerCloneNeedsRegeneration = HTTPHandler(struct { Path string Proxy string - Text string + Text *string }{}) // Clone makes a deep copy of WebServerConfig. diff --git a/ipn/ipn_view.go b/ipn/ipn_view.go index c117148da..5ec360e73 100644 --- a/ipn/ipn_view.go +++ b/ipn/ipn_view.go @@ -290,13 +290,19 @@ func (v *HTTPHandlerView) UnmarshalJSON(b []byte) error { func (v HTTPHandlerView) Path() string { return v.ж.Path } func (v HTTPHandlerView) Proxy() string { return v.ж.Proxy } -func (v HTTPHandlerView) Text() string { return v.ж.Text } +func (v HTTPHandlerView) Text() *string { + if v.ж.Text == nil { + return nil + } + x := *v.ж.Text + return &x +} // A compilation failure here means this code must be regenerated, with the command at the top of this file. var _HTTPHandlerViewNeedsRegeneration = HTTPHandler(struct { Path string Proxy string - Text string + Text *string }{}) // View returns a readonly view of WebServerConfig. diff --git a/ipn/ipnlocal/serve.go b/ipn/ipnlocal/serve.go index caac249f1..5dd251054 100644 --- a/ipn/ipnlocal/serve.go +++ b/ipn/ipnlocal/serve.go @@ -395,9 +395,9 @@ func (b *LocalBackend) serveWebHandler(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) return } - if s := h.Text(); s != "" { + if s := h.Text(); s != nil { w.Header().Set("Content-Type", "text/plain; charset=utf-8") - io.WriteString(w, s) + io.WriteString(w, *s) return } if v := h.Path(); v != "" { diff --git a/ipn/serve.go b/ipn/serve.go index 93d6b077e..2e38fcd5d 100644 --- a/ipn/serve.go +++ b/ipn/serve.go @@ -65,7 +65,7 @@ type HTTPHandler struct { Path string `json:",omitempty"` // absolute path to directory or file to serve Proxy string `json:",omitempty"` // http://localhost:3000/, localhost:3030, 3030 - Text string `json:",omitempty"` // plaintext to serve (primarily for testing) + Text *string `json:",omitempty"` // plaintext to serve (primarily for testing) // TODO(bradfitz): bool to not enumerate directories? TTL on mapping for // temporary ones? Error codes? Redirects? |
