Read the document from the given URI and return its contents. This default implementation of a ReadDocumentFunc only handles file: URIs and returns an error otherwise.
(u uri.URI)
| 82 | // implementation of a ReadDocumentFunc only handles file: URIs and returns an |
| 83 | // error otherwise. |
| 84 | func ReadDocument(u uri.URI) (contents []byte, err error) { |
| 85 | fn, err := filename(u) |
| 86 | if err != nil { |
| 87 | return nil, err |
| 88 | } |
| 89 | return os.ReadFile(fn) |
| 90 | } |
| 91 | |
| 92 | func filename(u uri.URI) (fn string, err error) { |
| 93 | defer func() { |