I have this net/http server setup with several middleware in a chain and I can't find examples on how I should test these...
I am using basic net/http with the gorilla/mux router and one Handle looks somewhat like this:
r.Handle("/documents", addCors(checkAPIKey(getDocuments(sendJSON)))).Methods("GET")
In these I aggregate some data and supply them via Gorilla Context context.Set methods.
Usually I test my http functions with httptest, and I hope to do it with these as well but I can't figure out how and I am curious as to what is the best way. Should I test each middleware seperately? Should I prefill the appropriate context values then when they are needed? Can I test this entire chain at once so I can just check desired states on input?
Aucun commentaire:
Enregistrer un commentaire