@@ -15,6 +15,7 @@ import (
15
15
16
16
"github.com/issue9/mux/v7"
17
17
"github.com/issue9/mux/v7/examples/std"
18
+ "github.com/issue9/mux/v7/header"
18
19
"github.com/issue9/mux/v7/internal/tree"
19
20
)
20
21
@@ -31,14 +32,14 @@ func TestRouterOf(t *testing.T) {
31
32
rest .NewRequest (a , http .MethodHead , "/" ).Do (r ).Status (201 ).BodyEmpty ()
32
33
rest .Get (a , "/abc" ).Do (r ).Status (http .StatusNotFound )
33
34
rest .NewRequest (a , http .MethodHead , "/200" ).Do (r ).Status (200 ).BodyEmpty () // 不调用 WriteHeader
34
- rest .NewRequest (a , http .MethodOptions , "*" ).Do (r ).Status (200 ).Header (" Allow" , "GET, OPTIONS" )
35
+ rest .NewRequest (a , http .MethodOptions , "*" ).Do (r ).Status (200 ).Header (header . Allow , "GET, OPTIONS" )
35
36
36
37
r .Get ("/h/1" , rest .BuildHandler (a , 201 , "" , nil ))
37
38
rest .Get (a , "/h/1" ).Do (r ).Status (201 )
38
39
39
40
r .Post ("/h/1" , rest .BuildHandler (a , 202 , "" , nil ))
40
41
rest .Post (a , "/h/1" , nil ).Do (r ).Status (202 )
41
- rest .NewRequest (a , http .MethodOptions , "*" ).Do (r ).Status (200 ).Header (" Allow" , "GET, OPTIONS, POST" )
42
+ rest .NewRequest (a , http .MethodOptions , "*" ).Do (r ).Status (200 ).Header (header . Allow , "GET, OPTIONS, POST" )
42
43
43
44
r .Put ("/h/1" , rest .BuildHandler (a , 203 , "" , nil ))
44
45
rest .Put (a , "/h/1" , nil ).Do (r ).Status (203 )
@@ -48,7 +49,7 @@ func TestRouterOf(t *testing.T) {
48
49
49
50
r .Delete ("/h/1" , rest .BuildHandler (a , 205 , "" , nil ))
50
51
rest .Delete (a , "/h/1" ).Do (r ).Status (205 )
51
- rest .NewRequest (a , http .MethodOptions , "*" ).Do (r ).Status (200 ).Header (" Allow" , "DELETE, GET, OPTIONS, PATCH, POST, PUT" )
52
+ rest .NewRequest (a , http .MethodOptions , "*" ).Do (r ).Status (200 ).Header (header . Allow , "DELETE, GET, OPTIONS, PATCH, POST, PUT" )
52
53
53
54
// Any
54
55
r .Any ("/h/any" , rest .BuildHandler (a , 206 , "" , nil ))
@@ -363,8 +364,8 @@ func TestPrefixOf(t *testing.T) {
363
364
return s == http .MethodGet || s == http .MethodPut || s == http .MethodHead // 删除了 GET,HEAD 也会删除。
364
365
})
365
366
slices .Sort (methods )
366
- rest .Get (a , "/p/h/any" ).Do (r ).Status (405 ).Header (" Allow" , strings .Join (methods , ", " )) // 已经删除
367
- rest .Delete (a , "/p/h/any" ).Do (r ).Status (206 ) // 未删除
367
+ rest .Get (a , "/p/h/any" ).Do (r ).Status (405 ).Header (header . Allow , strings .Join (methods , ", " )) // 已经删除
368
+ rest .Delete (a , "/p/h/any" ).Do (r ).Status (206 ) // 未删除
368
369
369
370
// clean
370
371
p .Clean ()
0 commit comments