|
@@ -8,13 +8,12 @@ package isokit
|
8
|
8
|
import (
|
9
|
9
|
"net/http"
|
10
|
10
|
|
11
|
|
- "github.com/go-humble/detect"
|
12
|
11
|
"github.com/gopherjs/gopherjs/js"
|
13
|
12
|
)
|
14
|
13
|
|
15
|
14
|
// ServerRedirect performs a redirect when operating on the server-side.
|
16
|
15
|
func ServerRedirect(w http.ResponseWriter, r *http.Request, destinationURL string) {
|
17
|
|
- http.Redirect(w, r, destinationURL, 301)
|
|
16
|
+ http.Redirect(w, r, destinationURL, 302)
|
18
|
17
|
}
|
19
|
18
|
|
20
|
19
|
// ClientRedirect performs a redirect when operating on the client-side.
|
|
@@ -30,11 +29,11 @@ func Redirect(items ...interface{}) {
|
30
|
29
|
var w http.ResponseWriter
|
31
|
30
|
var r *http.Request
|
32
|
31
|
|
33
|
|
- if detect.IsServer() && len(items) != 3 {
|
|
32
|
+ if OperatingEnvironment() == ServerEnvironment && len(items) != 3 {
|
34
|
33
|
return
|
35
|
34
|
}
|
36
|
35
|
|
37
|
|
- if detect.IsBrowser() && len(items) != 1 {
|
|
36
|
+ if OperatingEnvironment() == WebBrowserEnvironment && len(items) != 1 {
|
38
|
37
|
return
|
39
|
38
|
}
|
40
|
39
|
|
|
@@ -51,7 +50,7 @@ func Redirect(items ...interface{}) {
|
51
|
50
|
|
52
|
51
|
}
|
53
|
52
|
|
54
|
|
- if detect.IsServer() && (w == nil || r == nil) {
|
|
53
|
+ if OperatingEnvironment() == ServerEnvironment && (w == nil || r == nil) {
|
55
|
54
|
return
|
56
|
55
|
}
|
57
|
56
|
|
|
@@ -59,11 +58,11 @@ func Redirect(items ...interface{}) {
|
59
|
58
|
return
|
60
|
59
|
}
|
61
|
60
|
|
62
|
|
- switch {
|
63
|
|
- case detect.IsBrowser():
|
|
61
|
+ switch OperatingEnvironment() {
|
|
62
|
+ case WebBrowserEnvironment:
|
64
|
63
|
ClientRedirect(url)
|
65
|
64
|
|
66
|
|
- case detect.IsServer():
|
|
65
|
+ case ServerEnvironment:
|
67
|
66
|
ServerRedirect(w, r, url)
|
68
|
67
|
}
|
69
|
68
|
}
|