From 5c462bed2e40a01965b07afc14629ecbeec6ac47 Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Tue, 2 May 2017 23:52:25 -0600 Subject: [PATCH] Started article, just jotting down some notes --- Things-HTTP-Middleware-Developers-Should-Know.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Things-HTTP-Middleware-Developers-Should-Know.md diff --git a/Things-HTTP-Middleware-Developers-Should-Know.md b/Things-HTTP-Middleware-Developers-Should-Know.md new file mode 100644 index 0000000..2a8d990 --- /dev/null +++ b/Things-HTTP-Middleware-Developers-Should-Know.md @@ -0,0 +1,7 @@ +*Article is a WIP* + +- Use httpserver.Path to compare base paths to know if your handler should handle the request +- Don't touch the file system using a path from the request directly. Instead: + - To open a file, use http.Dir + - For anything else, use httpserver.SafePath to get a sanitized path +- If you need to wrap or record the response, wrap your own ResponseWriter type with httpserver.ResponseWriterWrapper so it is guaranteed to implement some crucial interfaces. \ No newline at end of file