-
Notifications
You must be signed in to change notification settings - Fork 1
/
redirect.go
52 lines (42 loc) · 1.27 KB
/
redirect.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"net/http"
"net/url"
)
// Redirect is a HTTP redirect.
type Redirect struct {
Status int
Location *url.URL
}
// MultipleChoices creates a 300 redirect.
func MultipleChoices(location *url.URL) *Redirect {
return &Redirect{http.StatusMultipleChoices, location}
}
// MovedPermanently creates a 301 redirect.
func MovedPermanently(location *url.URL) *Redirect {
return &Redirect{http.StatusMovedPermanently, location}
}
// Found creates a 302 redirect.
func Found(location *url.URL) *Redirect {
return &Redirect{http.StatusFound, location}
}
// SeeOther creates a 303 redirect.
func SeeOther(location *url.URL) *Redirect {
return &Redirect{http.StatusSeeOther, location}
}
// NotModified creates a 304 redirect.
func NotModified(location *url.URL) *Redirect {
return &Redirect{http.StatusNotModified, location}
}
// UseProxy creates a 305 redirect.
func UseProxy(location *url.URL) *Redirect {
return &Redirect{http.StatusUseProxy, location}
}
// TemporaryRedirect creates a 307 redirect.
func TemporaryRedirect(location *url.URL) *Redirect {
return &Redirect{http.StatusTemporaryRedirect, location}
}
// PermanentRedirect creates a 308 redirect.
func PermanentRedirect(location *url.URL) *Redirect {
return &Redirect{http.StatusPermanentRedirect, location}
}