// WellKnown returns an http.Handler which will serve the /.well-known/mesh.json // document for Endpoint. func WellKnown(e *e3x.Endpoint) http.Handler { return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { if req.Method != "GET" { http.NotFound(rw, req) return } if req.URL.Path != "/.well-known/mesh.json" { http.NotFound(rw, req) return } ident, err := e.LocalIdentity() if err != nil { http.NotFound(rw, req) return } rw.Header().Set("Content-Type", "application/json; charset=utf-8") rw.WriteHeader(200) json.NewEncoder(rw).Encode(ident) }) }