1
- package csrf
1
+ package shieldcsrf
2
2
3
3
import (
4
4
"net/http"
@@ -10,17 +10,19 @@ import (
10
10
11
11
var checksumSecret = "really-long-and-super-protected-checksum-secret"
12
12
13
- var safeMethods = []string {http .MethodGet , http .MethodHead , http .MethodOptions , http .MethodTrace }
14
- var unsafeMethods = []string {http .MethodPost , http .MethodPut , http .MethodPatch , http .MethodDelete }
15
- var testHandler = http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
16
- tok , err := FromRequest (r )
17
- if err != nil {
18
- http .Error (w , err .Error (), http .StatusInternalServerError )
19
- }
13
+ var (
14
+ safeMethods = []string {http .MethodGet , http .MethodHead , http .MethodOptions , http .MethodTrace }
15
+ unsafeMethods = []string {http .MethodPost , http .MethodPut , http .MethodPatch , http .MethodDelete }
16
+ testHandler = http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
17
+ tok , err := FromRequest (r )
18
+ if err != nil {
19
+ http .Error (w , err .Error (), http .StatusInternalServerError )
20
+ }
20
21
21
- SetToken (w , tok )
22
- _ , _ = w .Write ([]byte ("ok" ))
23
- })
22
+ SetToken (w , tok )
23
+ _ , _ = w .Write ([]byte ("ok" ))
24
+ })
25
+ )
24
26
25
27
func TestMethods (t * testing.T ) {
26
28
mux := http .NewServeMux ()
0 commit comments