rexyai / RestRserve

R web API framework for building high-performance microservices and app backends
https://restrserve.org
271 stars 31 forks source link

List somewhere that EncodeDecode middleware needs to be added in the last position after any other middleware. #175

Open duarteoctavio opened 3 years ago

duarteoctavio commented 3 years ago

Situation

Perhaps I'm getting something wrong, but after I added CORS middleware to my app, it started getting raw data instead of the type indicadted in the header, until I added the EncodeDecode middleware to the list, with the empty (default) parameters. Then, it worked.

Example

app = RestRserve::Application$new(
                                content_type="application/json",
                                middleware = list(
                                  CORSMiddleware$new(),
                                  EncodeDecodeMiddleware$new()
                                ),
                              )

Congratulations for coding this a amazing app!

dselivanov commented 3 years ago

Yes, default contsructor initialize EncodeDecodeMiddleware middleware. So when adding more than one you need to list all of them explicitly. May be we need to clarify this in docs.