Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (25 sloc) 1.02 KB
package main
import (
func main() {
app := iris.New()
app.Get("/", func(ctx context.Context) /* or iris.Context, it's the same for Go 1.9+. */ {
// GetReferrer extracts and returns the information from the "Referer" header as specified
// in or by the URL query parameter "referer".
r := ctx.GetReferrer()
switch r.Type {
case context.ReferrerSearch:
ctx.Writef("Search %s: %s\n", r.Label, r.Query)
ctx.Writef("Google: %s\n", r.GoogleType)
case context.ReferrerSocial:
ctx.Writef("Social %s\n", r.Label)
case context.ReferrerIndirect:
ctx.Writef("Indirect: %s\n", r.URL)
// http://localhost:8080?referer=
// http://localhost:8080?referer=
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed))
You can’t perform that action at this time.