Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 752 Bytes

README.md

File metadata and controls

44 lines (31 loc) · 752 Bytes

referrer

Build Status GoDoc



example

package main

import (
	"log"
	"net/http"

	"github.com/saihon/referrer"
)

func main() {
	r := referrer.New()
	r.SetPolicy(referrer.POLICY_ORIGIN_WHEN_CROSS_ORIGIN)

	fromURL := "http://example.com/from"
	toURL := "http://example.com/to"

	req, err := http.NewRequest(`GET`, toURL, nil)
	if err != nil {
		log.Fatal(err)
	}

	referer, ok := r.Make(fromURL, toURL)
	// set referer
	if ok {
		req.Header.Set("Referer", referer)
	}

	http.DefaultClient.Do(req)
}