@@ -85,6 +85,7 @@ func (m *EndpointMeta) validate() {
8585 if m .Pattern == "" {
8686 panic ("Endpoint.Path is required" )
8787 }
88+
8889 if m .StatusCode == 0 {
8990 panic ("Endpoint.StatusCode is required" )
9091 }
@@ -142,13 +143,15 @@ func executeAPIEndpoint[TReq any, TResp any](w http.ResponseWriter, r *http.Requ
142143
143144 err := func () error {
144145 var req TReq
146+
145147 if r .Method != http .MethodGet {
146148 reqData , err := io .ReadAll (r .Body )
147149 if err != nil {
148150 var maxBytesErr * http.MaxBytesError
149151 if errors .As (err , & maxBytesErr ) {
150152 return apierror .NewRequestEntityTooLarge ("Request entity too large." )
151153 }
154+
152155 return fmt .Errorf ("error reading request body: %w" , err )
153156 }
154157
@@ -213,12 +216,14 @@ func executeAPIEndpoint[TReq any, TResp any](w http.ResponseWriter, r *http.Requ
213216 logger .InfoContext (ctx , "API error response" , logAttrs ... )
214217
215218 apiErr .Write (ctx , logger , w )
219+
216220 return
217221 }
218222
219223 if errors .Is (err , context .DeadlineExceeded ) {
220224 logger .ErrorContext (ctx , "request timeout" , slog .String ("error" , err .Error ()))
221225 apierror .NewServiceUnavailable ("Request timed out. Retrying the request might work." ).Write (ctx , logger , w )
226+
222227 return
223228 }
224229
0 commit comments