Tags: aquasecurity/lmdrouter
Tags
Implement net/http.Handler for local development This commit modifies the lmdrouter.Router type to implement the net/http.Handler interface (meaning the ServeHTTP method is now available on *lmdrouter.Route objects). This allows usage of applications using lmdrouter in environments other than AWS Lambda, but is mostly useful for local development purposes. It should be noted that this means applications will now have to use the `netgo` build tag (`go build -tags netgo`) to make sure binaries are still statically compiled. Resolves: 1
Support optional boolean query parameters (i.e. pointers) This commit adds support for boolean query parameters that are optional, meaning their type is `*bool` rather than `bool`. This is useful in cases where an API must know whether the parameter was actually provided, even if it was false, and not just received a zero value.
Bugfix: UnmarshalRequest may misbehave for requests with a body When a request includes a body, and `UnmarshalRequest` is called with `body = true`, then the function only unmarshals the JSON body into the target struct. However, if the target struct also includes fields for query/path/header parameters (i.e. fields with a "lambda" struct tag), then they were not parsed. To fix, the request body will first be unmarshaled into the target struct, and then the rest of the parameters (if any) will be processed as well.
Add ability to not expose server errors This commit adds the ability to not expose HTTP errors whose status code is 500 or above (i.e. server errors) when the HandleError function is used. This is done by setting the ExposeServerErrors global variable to false. Tests for the HandleError function are also added.