<p>So my current project is using github.com/gorilla/mux for the handling, i also need to have a file server on it, it will just list all files in a directory and allow the browser to download or look at them. I am currently doing this bellow</p>
<p>router.PathPrefix("/files/").Handler(http.StripPrefix("/files/", http.FileServer(http.Dir("./Profiles/"))))</p>
<p>I need to protect this page so that not just anyone can see it and get the files... Whats the most simple way i can do this?</p>
<hr/>**评论:**<br/><br/>luckyleprechaun98: <pre><p>Yep basic auth is the way to go. You can use a middleware but you still need TLS to keep it secure. At that point it's easier to stick <a href="https://caddyserver.com" rel="nofollow">Caddy</a> in front and use its basic auth directive. It will set up TLS for you automatically. </p></pre>tgulacsi: <pre><p>See <a href="http://elithrar.github.io/article/httpauth-basic-auth-for-go/" rel="nofollow">http://elithrar.github.io/article/httpauth-basic-auth-for-go/</a> </p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传