Skip to content

Commit 66f6b62

Browse files
docs: adding example for fasthttp (#87)
* docs(go-sdk): adding example for fasthttp * docs(go-sdk): adding example for fasthttp
1 parent f06bf26 commit 66f6b62

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

+36
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,42 @@ func main(){
233233
http.ListenAndServe(":"+port, r)
234234
}
235235
```
236+
### 6. FastHttp
237+
```go
238+
mw := kfasthttp.FastHttpMiddleware(k)
239+
```
240+
#### Example
241+
```go
242+
import(
243+
"github.com/keploy/go-sdk/integrations/kfasthttp"
244+
"github.com/keploy/go-sdk/keploy"
245+
"github.com/valyala/fasthttp"
246+
)
247+
248+
func main() {
249+
k := keploy.New(keploy.Config{
250+
App: keploy.AppConfig{
251+
Name: "fasthttp-URL",
252+
Port: "8080",
253+
},
254+
Server: keploy.ServerConfig{
255+
URL: "http://localhost:8081/api",
256+
},
257+
})
258+
259+
mw := kfasthttp.FastHttpMiddleware(k)
260+
m := func(ctx *fasthttp.RequestCtx) {
261+
switch string(ctx.Path()) {
262+
case "/index":
263+
index(ctx)
264+
default:
265+
ctx.Error("not found", fasthttp.StatusNotFound)
266+
}
267+
}
268+
log.Fatal(fasthttp.ListenAndServe(":8080", mw(m)))
269+
}
270+
```
271+
236272

237273
## Supported Databases
238274
### 1. MongoDB

0 commit comments

Comments
 (0)