mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'
This commit is contained in:
53
docs/content/en/methods/resource/Data.md
Normal file
53
docs/content/en/methods/resource/Data.md
Normal file
@@ -0,0 +1,53 @@
|
||||
---
|
||||
title: Data
|
||||
description: Applicable to resources returned by the resources.GetRemote function, returns information from the HTTP response.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/resources/GetRemote
|
||||
- methods/resource/Err
|
||||
returnType: map
|
||||
signatures: [RESOURCE.Data]
|
||||
---
|
||||
|
||||
The `Data` method on a resource returned by the [`resources.GetRemote`] function returns information from the HTTP response.
|
||||
|
||||
[`resources.GetRemote`]: functions/resources/getremote
|
||||
|
||||
```go-html-template
|
||||
{{ $url := "https://example.org/images/a.jpg" }}
|
||||
{{ with resources.GetRemote $url }}
|
||||
{{ with .Err }}
|
||||
{{ errorf "%s" . }}
|
||||
{{ else }}
|
||||
{{ with .Data }}
|
||||
{{ .ContentLength }} → 42764
|
||||
{{ .ContentType }} → image/jpeg
|
||||
{{ .Status }} → 200 OK
|
||||
{{ .StatusCode }} → 200
|
||||
{{ .TransferEncoding }} → []
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ errorf "Unable to get remote resource %q" $url }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
ContentLength
|
||||
: (`int`) The content length in bytes.
|
||||
|
||||
ContentType
|
||||
: (`string`) The content type.
|
||||
|
||||
Status
|
||||
: (`string`) The HTTP status text.
|
||||
|
||||
StatusCode
|
||||
: (`int`) The HTTP status code.
|
||||
|
||||
TransferEncoding
|
||||
: (`string`) The transfer encoding.
|
||||
|
||||
|
||||
[`resources.GetRemote`]: functions/resources/getremote
|
Reference in New Issue
Block a user