@@ -17,7 +17,22 @@ func buildFsRoutes(spacePrimitives SpacePrimitives, spacePath string) http.Handl
1717 fsRouter := chi .NewRouter ()
1818
1919 // File list endpoint
20- fsRouter .Get ("/" , func (w http.ResponseWriter , r * http.Request ) {
20+ fsRouter .Get ("/" , handleFsList (spacePrimitives , spacePath ))
21+
22+ // File operations
23+ fsRouter .Get ("/*" , handleFsGet (spacePrimitives ))
24+ fsRouter .Put ("/*" , handleFsPut (spacePrimitives ))
25+ fsRouter .Delete ("/*" , handleFsDelete (spacePrimitives ))
26+ fsRouter .Options ("/*" , func (w http.ResponseWriter , r * http.Request ) {
27+ w .Header ().Set ("Allow" , "GET, PUT, DELETE, OPTIONS" )
28+ w .WriteHeader (http .StatusOK )
29+ })
30+
31+ return fsRouter
32+ }
33+
34+ func handleFsList (spacePrimitives SpacePrimitives , spacePath string ) http.HandlerFunc {
35+ return func (w http.ResponseWriter , r * http.Request ) {
2136 if r .Header .Get ("X-Sync-Mode" ) != "" {
2237 // Handle direct requests for JSON representation of file list
2338 files , err := spacePrimitives .FetchFileList ()
@@ -27,23 +42,11 @@ func buildFsRoutes(spacePrimitives SpacePrimitives, spacePath string) http.Handl
2742 }
2843 w .Header ().Set ("X-Space-Path" , spacePath )
2944 render .JSON (w , r , files )
30-
3145 } else {
3246 // Otherwise, redirect to the UI
3347 http .Redirect (w , r , "/" , http .StatusTemporaryRedirect )
3448 }
35- })
36-
37- // File operations
38- fsRouter .Get ("/*" , handleFsGet (spacePrimitives ))
39- fsRouter .Put ("/*" , handleFsPut (spacePrimitives ))
40- fsRouter .Delete ("/*" , handleFsDelete (spacePrimitives ))
41- fsRouter .Options ("/*" , func (w http.ResponseWriter , r * http.Request ) {
42- w .Header ().Set ("Allow" , "GET, PUT, DELETE, OPTIONS" )
43- w .WriteHeader (http .StatusOK )
44- })
45-
46- return fsRouter
49+ }
4750}
4851
4952// handleFsGet handles GET requests for individual files
0 commit comments