<p>I am building a Vue.js based frontend. Till today I was writing the front end, but now I want to check how it deals with the backend, there are two options I have</p>
<ol>
<li>Write the backend</li>
<li>Use a tool which would simulate the backend</li>
</ol>
<p>I tried looking on Github, but didn't find any tool regarding this requirement.</p>
<hr/>**评论:**<br/><br/>quiI: <pre><p>Shameless plug time! </p>
<p><a href="https://github.com/quii/mockingjay-server" rel="nofollow">https://github.com/quii/mockingjay-server</a></p>
<p>It's pretty well battle-tested, used a lot in my current job and a little in my previous one too. Well over a year of incremental improvements but always happy for more feedback to take on.</p></pre>thewhitetulip: <pre><p>Thank you for this! (it isn't a shameless plug if it related to the topic)</p>
<p>Is this a part of awesome-go? It'd be great if it was (in case it is a part and I wasn't able to find it)</p>
<p>edit: go get throws this error</p>
<p>../../quii/mockingjay-server/main.go:45: undefined: assetFS</p></pre>quiI: <pre><p>Yeah someone (you?) raised an issue. It's because we always use the docker image version which has everything bundled. Nonetheless I should fix the bug and will try and look into it this weekend</p></pre>thewhitetulip: <pre><p>Yes, I raised it :-) </p>
<p>By the way, I am getting "unexpected EOF" while reading a html file, any ideas/suggestions?</p></pre>quiI: <pre><p>Not sure, could you try explaining the steps? </p>
<p>I think i have made it go-get-able again now, sorry about that</p></pre>thewhitetulip: <pre><p>The go get is working, it was a mistake I had made.</p></pre>: <pre><p>[deleted]</p></pre>thewhitetulip: <pre><p>not exactly, I want to mock an endpoint like this</p>
<p><code>GET /tasks</code> should return a JSON containing my tasks.</p>
<p>It should fake an http server, it is to test my front end is working or not before I write the backend code.</p></pre>: <pre><p>[deleted]</p></pre>thewhitetulip: <pre><p><code>PUT</code> should not return anything. I want to check if rendering is running correctly before I write my backend. But I do realize that writing a backend is probably a faster way than writing a tool to simulate a http server. also, <a href="https://github.com/quii/mockingjay-server" rel="nofollow">https://github.com/quii/mockingjay-server</a> seems like the thing I was searching for.</p></pre>titpetric: <pre><p>I usually start with nginx (but any web server will do). The most "stupid" example of a mocked back-end api is just an API folder with several json files stored within it, which then the front-end is requesting.</p>
<p>I wrote a <a href="https://github.com/titpetric/gallery-angular" rel="nofollow">gallery-angular</a> project a while back, so I could see what the fuss with Angular was about, and I created a generator that would create these json files from whatever folder structures/images (script run in the same repo). Think of it like a 'hugo' for API endpoints. The principle is quite useful.</p></pre>thewhitetulip: <pre><p>this is a good idea, but if we have several json files stored in a file, the files will be rendered right? I want JSON response and not file rendering.</p></pre>phonkee: <pre><p>You can use my <a href="https://github.com/phonkee/goexpose" rel="nofollow">https://github.com/phonkee/goexpose</a> which gives you ability to run shell commands, and a lot more.</p></pre>thewhitetulip: <pre><p>Thank you!</p></pre>sethammons: <pre><p>Another shameless plug:
<a href="https://github.com/sethgrid/fakettp" rel="nofollow">https://github.com/sethgrid/fakettp</a></p>
<p>Fakettp is a light http reverse debugging proxy. What that means for you: you can let requests go through to downstream dependencies or highjack them and force a delay or to change the response. I've not used it as a complete stand in for a remote service, though it will work for that. My typical use case is that I have a complex app where I don't want to mock out all the interactions, and I just want to mock one particular endpoint to validate my error handling. </p></pre>thewhitetulip: <pre><p>I came across your repo in my search. Thank you :-)</p>
<p>By the way, I ended up writing my API, I had it partially up & running earlier. Will use fakettp while testing!</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传