3 ms·
I had the same questions, so I went ahead and prototyped a tiny API in Go: https://github.com/melvinmt/translation.io https://github.com/melvinmt/translation.io
by melvinmt 13y ago
I had the same questions, so I went ahead and prototyped a tiny API in Go: https://github.com/melvinmt/translation.io https://github.com/melvinmt/translation.io
Building an API in Go feels -very- robust because of the strong typing and the strict compiler. After a while you'll discover the strength of interfaces and be pleasantly surprised. Combined with the performance boost, I can't think of a better language to write an API in.
- agentS 13y agoFYI, 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.
- melvinmt 13y agoThanks! Didn't know about Fileserver. I'll look into it.