Hacker News new | ask | show | jobs
by agentS 4778 days ago
FYI, you should replace DocsHandler with net/http's FileServer.

Reasons: 1) the implementation is not vulnerable to path traversal attacks (i.e. if url.Path == "/../../../../../etc/passwd"). 2) It automatically handles index.html 3) It uses "/etc/mime.types" and other system files to automatically set mime types 4) It streams the file back instead of reading it all into memory.

1 comments

Thanks! Didn't know about Fileserver. I'll look into it.