1
1
package main
2
2
3
- //go:generate depstubber -vendor github.com/beego/beego/v2/server/web Controller Run,Router
4
- //go:generate depstubber -vendor github.com/beego/beego/v2/server/web/context BeegoOutput,Context
5
- //go:generate depstubber -vendor github.com/gin-gonic/gin Context Default
6
- //go:generate depstubber -vendor github.com/gofiber/fiber/v2 Ctx New
7
- //go:generate depstubber -vendor github.com/kataras/iris/v12/context Context
8
- //go:generate depstubber -vendor github.com/labstack/echo/v4 Context New
9
3
//go:generate depstubber -vendor github.com/spf13/afero Afero,RegexpFs,HttpFs,ReadOnlyFs,MemMapFs,OsFs,BasePathFs WriteReader,SafeWriteReader,WriteFile,ReadFile,ReadDir,NewOsFs,NewRegexpFs,NewReadOnlyFs,NewCacheOnReadFs,,NewHttpFs,NewBasePathFs,NewIOFS
10
4
11
5
import (
12
6
"fmt"
13
- beego "github.com/beego/beego/v2/server/web"
14
- BeegoContext "github.com/beego/beego/v2/server/web/context"
15
- "github.com/gin-gonic/gin"
16
- "github.com/gofiber/fiber/v2"
17
- "github.com/kataras/iris/v12/context"
18
- "github.com/labstack/echo/v4"
19
7
"github.com/spf13/afero"
20
8
"net/http"
21
9
"os"
@@ -26,13 +14,6 @@ func main() {
26
14
return
27
15
}
28
16
29
- func BeegoController (beegoController beego.Controller ) {
30
- beegoOutput := BeegoContext.BeegoOutput {}
31
- beegoOutput .Download ("filepath" , "license.txt" ) // $ FileSystemAccess="filepath"
32
- buffer := make ([]byte , 10 )
33
- _ = beegoController .SaveToFileWithBuffer ("filenameExistsInForm" , "filepath" , buffer ) // $ FileSystemAccess="filepath"
34
- }
35
-
36
17
func Afero (writer http.ResponseWriter , request * http.Request ) {
37
18
filepath := request .URL .Query ()["filepath" ][0 ]
38
19
//osFS := afero.NewMemMapFs()
@@ -97,52 +78,3 @@ func Afero(writer http.ResponseWriter, request *http.Request) {
97
78
fmt .Println (afero .ReadFile (basePathFs , filepath ))
98
79
afero .ReadFile (basePathFs , filepath )
99
80
}
100
-
101
- func Echo () {
102
- e := echo .New ()
103
- e .GET ("/" , func (c echo.Context ) error {
104
- filepath := c .QueryParam ("filePath" )
105
- return c .File (filepath ) // $ FileSystemAccess=filepath
106
- })
107
-
108
- e .GET ("/attachment" , func (c echo.Context ) error {
109
- filepath := c .QueryParam ("filePath" )
110
- return c .Attachment (filepath , "file name in response" ) // $ FileSystemAccess=filepath
111
- })
112
- _ = e .Start (":1323" )
113
- }
114
-
115
- func Fiber () {
116
- app := fiber .New ()
117
- app .Get ("/b" , func (c * fiber.Ctx ) error {
118
- filepath := c .Params ("filepath" )
119
- header , _ := c .FormFile ("f" )
120
- _ = c .SaveFile (header , filepath ) // $ FileSystemAccess=filepath
121
- return c .SendFile (filepath ) // $ FileSystemAccess=filepath
122
- })
123
- _ = app .Listen (":3000" )
124
- }
125
-
126
- func IrisTest (ctx context.Context ) {
127
- filepath := ctx .URLParam ("filepath" )
128
- _ = ctx .SendFile (filepath , "file" ) // $ FileSystemAccess=filepath
129
- _ = ctx .SendFileWithRate (filepath , "file" , 0 , 0 ) // $ FileSystemAccess=filepath
130
- _ = ctx .ServeFile (filepath ) // $ FileSystemAccess=filepath
131
- _ = ctx .ServeFileWithRate (filepath , 0 , 0 ) // $ FileSystemAccess=filepath
132
- _ , _ , _ = ctx .UploadFormFiles (filepath , nil ) // $ FileSystemAccess=filepath
133
- _ , fileHeader , _ := ctx .FormFile ("file" )
134
- _ , _ = ctx .SaveFormFile (fileHeader , filepath ) // $ FileSystemAccess=filepath
135
-
136
- }
137
- func Gin () {
138
- router := gin .Default ()
139
- router .POST ("/FormUploads" , func (c * gin.Context ) {
140
- filepath := c .Query ("filepath" )
141
- c .File (filepath ) // $ FileSystemAccess=filepath
142
- http .ServeFile (c .Writer , c .Request , filepath ) // $ FileSystemAccess=filepath
143
- c .FileAttachment (filepath , "file name in response" ) // $ FileSystemAccess=filepath
144
- file , _ := c .FormFile ("afile" )
145
- _ = c .SaveUploadedFile (file , filepath ) // $ FileSystemAccess=filepath
146
- })
147
- _ = router .Run ()
148
- }
0 commit comments