@@ -76,7 +76,7 @@ func (h handlerStruct) ServeHTTP(w http.ResponseWriter, r *http.Request) {
76
76
}
77
77
78
78
func TestRouterAPI (t * testing.T ) {
79
- var get , head , post , put , patch , delete , handler , handlerFunc bool
79
+ var get , head , options , post , put , patch , delete , handler , handlerFunc bool
80
80
81
81
httpHandler := handlerStruct {& handler }
82
82
@@ -87,6 +87,9 @@ func TestRouterAPI(t *testing.T) {
87
87
router .HEAD ("/GET" , func (w http.ResponseWriter , r * http.Request , _ Params ) {
88
88
head = true
89
89
})
90
+ router .OPTIONS ("/GET" , func (w http.ResponseWriter , r * http.Request , _ Params ) {
91
+ options = true
92
+ })
90
93
router .POST ("/POST" , func (w http.ResponseWriter , r * http.Request , _ Params ) {
91
94
post = true
92
95
})
@@ -118,6 +121,12 @@ func TestRouterAPI(t *testing.T) {
118
121
t .Error ("routing HEAD failed" )
119
122
}
120
123
124
+ r , _ = http .NewRequest ("OPTIONS" , "/GET" , nil )
125
+ router .ServeHTTP (w , r )
126
+ if ! head {
127
+ t .Error ("routing OPTIONS failed" )
128
+ }
129
+
121
130
r , _ = http .NewRequest ("POST" , "/POST" , nil )
122
131
router .ServeHTTP (w , r )
123
132
if ! post {
0 commit comments