Situation:
I'm building a REST API using Gorilla's mux as the router.
I'm wondering how I can protect specific routes with simple HTTP Basic Auth. I don't have a need to read the credentials from a file or any external source, I really just want to protect selected routes by a hard coded HTTP Basic Auth username and password.
Question:
What is the idiomatic way of doing so in Go? Does Gorilla offer anything to make it more easy? If you could provide a few lines of code, that would be just wonderful.
question from:
https://stackoverflow.com/questions/21936332/idiomatic-way-of-requiring-http-basic-auth-in-go 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…