@@ -76,19 +76,28 @@ func TestEchoStatic(t *testing.T) {
7676
7777// Directory
7878e .Static ("/images" , "_fixture/images" )
79- c , _ = request (http .MethodGet , "/images" , e )
79+ c , _ = request (http .MethodGet , "/images/ " , e )
8080assert .Equal (http .StatusNotFound , c )
8181
82+ // Directory Redirect
83+ e .Static ("/" , "_fixture" )
84+ req := httptest .NewRequest (http .MethodGet , "/folder" , nil )
85+ rec := httptest .NewRecorder ()
86+ e .ServeHTTP (rec , req )
87+ assert .Equal (http .StatusMovedPermanently , rec .Code )
88+ assert .Equal ("/folder/" , rec .HeaderMap ["Location" ][0 ])
89+
8290// Directory with index.html
8391e .Static ("/" , "_fixture" )
8492c , r := request (http .MethodGet , "/" , e )
8593assert .Equal (http .StatusOK , c )
8694assert .Equal (true , strings .HasPrefix (r , "<!doctype html>" ))
8795
8896// Sub-directory with index.html
89- c , r = request (http .MethodGet , "/folder" , e )
97+ c , r = request (http .MethodGet , "/folder/ " , e )
9098assert .Equal (http .StatusOK , c )
9199assert .Equal (true , strings .HasPrefix (r , "<!doctype html>" ))
100+
92101}
93102
94103func TestEchoFile (t * testing.T ) {
0 commit comments