- main
- manifest
- deps
- main
- Install
- Run
package main
import (
"context"
"fmt"
"io"
"github.com/fastly/compute-sdk-go/fsthttp"
)
const BackendName = "origin_0"
func main() {
fsthttp.ServeFunc(func(ctx context.Context, w fsthttp.ResponseWriter, r *fsthttp.Request) {
resp, err := r.Send(ctx, BackendName)
if err != nil {
w.WriteHeader(fsthttp.StatusBadGateway)
fmt.Fprintln(w, err.Error())
return
}
resp.Header.Set("cache-control", "private, no-store")
resp.Header.Del("expires")
resp.Header.Del("etag")
resp.Header.Del("last-modified")
w.Header().Reset(resp.Header)
w.WriteHeader(resp.StatusCode)
io.Copy(w, resp.Body)
})
}