@@ -5,9 +5,12 @@ package fiberadapter
5
5
6
6
import (
7
7
"context"
8
- "io/ioutil"
8
+ "fmt"
9
+ "io"
10
+ "log"
9
11
"net"
10
12
"net/http"
13
+ "strings"
11
14
12
15
"github.com/aws/aws-lambda-go/events"
13
16
"github.com/gofiber/fiber/v2"
@@ -103,7 +106,7 @@ func (f *FiberLambda) adaptor(w http.ResponseWriter, r *http.Request) {
103
106
defer fasthttp .ReleaseRequest (req )
104
107
105
108
// Convert net/http -> fasthttp request
106
- body , err := ioutil .ReadAll (r .Body )
109
+ body , err := io .ReadAll (r .Body )
107
110
if err != nil {
108
111
http .Error (w , utils .StatusMessage (fiber .StatusInternalServerError ), fiber .StatusInternalServerError )
109
112
return
@@ -129,8 +132,16 @@ func (f *FiberLambda) adaptor(w http.ResponseWriter, r *http.Request) {
129
132
}
130
133
}
131
134
132
- remoteAddr , err := net .ResolveTCPAddr ("tcp" , r .RemoteAddr )
135
+ // We need to make sure the net.ResolveTCPAddr call works as it expects a port
136
+ addrWithPort := r .RemoteAddr
137
+ if ! strings .Contains (r .RemoteAddr , ":" ) {
138
+ addrWithPort = r .RemoteAddr + ":80" // assuming a default port
139
+ }
140
+
141
+ remoteAddr , err := net .ResolveTCPAddr ("tcp" , addrWithPort )
133
142
if err != nil {
143
+ fmt .Printf ("could not resolve TCP address for addr %s\n " , r .RemoteAddr )
144
+ log .Println (err )
134
145
http .Error (w , utils .StatusMessage (fiber .StatusInternalServerError ), fiber .StatusInternalServerError )
135
146
return
136
147
}
0 commit comments