Help needed with my URL Shortener Microservice...

polaris · · 736 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;m currently trying to build a URL shortener microservice in Go for FreeCodeCamp, and I need a bit of help. I&#39;ve tried asking on StackOverflow and the FreeCodeCamp forum but nobody seems willing, or able, to help.</p> <p>I&#39;ve got most of my other code running but when I add a url to the end of the api route (i.e. <a href="https://morning-retreat-24523.herokuapp.com/new/https://www.google.com" rel="nofollow">https://morning-retreat-24523.herokuapp.com/new/https://www.google.com</a>) a forward slash gets removed so that it ends up as: <a href="https://morning-retreat-24523.herokuapp.com/new/https:/www.google.com" rel="nofollow">https://morning-retreat-24523.herokuapp.com/new/https:/www.google.com</a> and then throws a &#39;404 page not found&#39; error.</p> <p>My github repo is here: <a href="https://github.com/AndrewRMorgan/url-shortener" rel="nofollow">https://github.com/AndrewRMorgan/url-shortener</a></p> <p>Its getting really frustrating, it seems like all the other apps built in node don&#39;t seem to need to do anything special to make this work so I suppose I&#39;m just wondering what I might be doing wrong?</p> <hr/>**评论:**<br/><br/>HectorJ: <pre><p><a href="https://github.com/AndrewRMorgan/url-shortener/pull/1" rel="nofollow">https://github.com/AndrewRMorgan/url-shortener/pull/1</a></p> <p>Haven&#39;t tested it, but that should do the job, I think.</p></pre>philstudent123: <pre><p>Thanks HectorJ, that did the trick. Now I just need to figure out why it&#39;s still giving me a 404 error haha.</p></pre>softwaregav: <pre><p>I think I saw this on SO, and they told you the same thing. You need to URL encode the URL you&#39;re sending as a parameter. It&#39;s probably being parsed differently than you think. I&#39;ll check it out when I get home from class.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

736 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传