package main
import (
	"context"
	"fmt"
	"io"
	"regexp"
	"github.com/fastly/compute-sdk-go/fsthttp"
)
const Backend = "origin_0"
var PathMatch = regexp.MustCompile(`^/some-(custom|dynamic|complex)-pattern/url/path$`)
func main() {
	fsthttp.ServeFunc(func(ctx context.Context, w fsthttp.ResponseWriter, r *fsthttp.Request) {
		
		if PathMatch.MatchString(r.URL.Path) {
			r.URL.Path = "/status/200"
		}
		
		resp, err := r.Send(ctx, Backend)
		if err != nil {
			w.WriteHeader(fsthttp.StatusBadGateway)
			fmt.Fprintln(w, err)
			return
		}
		
		w.Header().Reset(resp.Header)
		w.WriteHeader(resp.StatusCode)
		io.Copy(w, resp.Body)
	})
}