This is the authentication page. Eventually it will include explanations of:
We get our latitude and longitude from a geoip service and use it to request data from a weather service. The weather service requires authentication using an API key, which we have uploaded as a secret using Wrangler.
<script type="edgeside/request-data"
data-edgeside-output="requestData">
</script>
<script type="edgeside/rest"
data-edgeside-input="requestData"
data-edgeside-output="location"
data-edgeside-endpoint="https://freegeoip.app/json/$ip"
data-edgeside-parameter-map="$ip:${headers['cf-connecting-ip']}" >
</script>
<script type="edgeside/rest"
data-edgeside-input="location"
data-edgeside-output="weather"
data-edgeside-endpoint="https://api.openweathermap.org/data/2.5/weather?units=Metric"
data-edgeside-parameter-map="appid:${OWM_API_KEY},lat:${latitude},lon:${longitude}">
</script>
<script type="edgeside/template"
data-edgeside-input="weather">
<img src="http://openweathermap.org/img/wn/{{weather.0.icon}}@4x.png" alt="weather icon">
<div>
<p>{{name}}</p>
<p>{{weather.0.description}}</p>
<p>{{main.temp}}°C</p>
</div>
</script>
This time we get some pictures of cats in sunglasses, passing an API key to the cat service via a request header
<script type="edgeside/rest"
data-edgeside-output="cats"
data-edgeside-endpoint="https://api.thecatapi.com/v1/favourites"
data-edgeside-parameter-map="#x-api-key:${CAT_API_KEY}">
</script>
<script type="edgeside/template"
data-edgeside-input="cats">
{{#.}}
<img src="{{image.url}}">
{{/.}}
</script>