@@ -21,7 +21,7 @@ Simple HTTP adapter for AWS Lambda
21
21
package main
22
22
23
23
import (
24
- " github.com/its-felix/aws-lambda-go-http-adapter/adapter/vanilla "
24
+ " github.com/its-felix/aws-lambda-go-http-adapter/adapter"
25
25
" net/http"
26
26
)
27
27
@@ -32,7 +32,7 @@ func main() {
32
32
_, _ = w.Write ([]byte (" pong" ))
33
33
})
34
34
35
- adapter := vanilla. NewAdapter (mux)
35
+ adapter := adapter. NewVanillaAdapter (mux)
36
36
}
37
37
```
38
38
@@ -42,7 +42,7 @@ package main
42
42
43
43
import (
44
44
" github.com/labstack/echo/v4"
45
- echoadapter " github.com/its-felix/aws-lambda-go-http-adapter/adapter/echo "
45
+ " github.com/its-felix/aws-lambda-go-http-adapter/adapter"
46
46
" net/http"
47
47
)
48
48
@@ -52,7 +52,7 @@ func main() {
52
52
return c.String (200 , " pong" )
53
53
})
54
54
55
- adapter := echoadapter. NewAdapter (e)
55
+ adapter := adapter. NewEchoAdapter (e)
56
56
}
57
57
```
58
58
@@ -62,8 +62,7 @@ package main
62
62
63
63
import (
64
64
" github.com/gofiber/fiber/v2"
65
- fiberadapter " github.com/its-felix/aws-lambda-go-http-adapter/adapter/fiber"
66
- " net/http"
65
+ " github.com/its-felix/aws-lambda-go-http-adapter/adapter"
67
66
)
68
67
69
68
func main () {
@@ -72,7 +71,7 @@ func main() {
72
71
return ctx.SendString (" pong" )
73
72
})
74
73
75
- adapter := fiberadapter. NewAdapter (app)
74
+ adapter := adapter. NewFiberAdapter (app)
76
75
}
77
76
```
78
77
@@ -129,6 +128,7 @@ func main() {
129
128
```
130
129
131
130
#### Lambda Function URL (streaming)
131
+ (read the additional notes about streaming below)
132
132
``` golang
133
133
package main
134
134
@@ -153,13 +153,13 @@ package main
153
153
import (
154
154
" github.com/aws/aws-lambda-go/events"
155
155
" github.com/gofiber/fiber/v2"
156
- fiberadapter " github.com/its-felix/aws-lambda-go-http-adapter/adapter/fiber "
156
+ " github.com/its-felix/aws-lambda-go-http-adapter/adapter"
157
157
)
158
158
159
159
func main () {
160
160
app := fiber.New ()
161
161
app.Get (" /ping" , func (ctx *fiber.Ctx ) error {
162
- event := fiberadapter. GetSourceEvent (ctx)
162
+ event := adapter. GetSourceEventFiber (ctx)
163
163
switch event := event.(type ) {
164
164
case events.APIGatewayProxyRequest :
165
165
// do something
@@ -238,9 +238,9 @@ Have a look at the existing event handlers:
238
238
239
239
## Extending for other frameworks
240
240
Have a look at the existing adapters:
241
- - [ net/http] ( ./adapter/vanilla/vanilla .go )
242
- - [ Echo] ( ./adapter/echo/echo .go )
243
- - [ Fiber] ( ./adapter/fiber/fiber .go )
241
+ - [ net/http] ( ./adapter/vanilla.go )
242
+ - [ Echo] ( ./adapter/echo.go )
243
+ - [ Fiber] ( ./adapter/fiber.go )
244
244
245
245
## Build Tags
246
246
You can opt-in to enable partial build by using the build-tag ` lambdahttpadapter.partial ` .
@@ -254,4 +254,10 @@ Once this build-tag is present, the following build-tags are available:
254
254
- ` lambdahttpadapter.functionurl ` (enables Lambda Function URL handler)
255
255
256
256
Also note that Lambda Function URL in Streaming-Mode requires the following build-tag to be set:
257
- - ` lambda.norpc `
257
+ - ` lambda.norpc `
258
+
259
+ ## Note about Lambda streaming
260
+ Response streaming is currently not supported for the fiber adapter.
261
+ The code will work, but the response body will only be sent downstream as soon as the request was processed completely.
262
+
263
+ This is because there seems to be no way in ` fasthttp ` to provide a ` io.Writer ` to be populated while the request is being processed.
0 commit comments