Using electron to develop a H5 client application create HTTP service mock backend interface mock

Source: Internet
Author: User

Developing a H5 client application using electron to create an HTTP service to emulate backend interface mock

In the last "electron quick start" described how to quickly start an electron application, since electron can directly use the node environment to write programs, then we can have a lot of things to deal with, such as we can do a visual front-end building tools, Or we can build a backend management system. Based on these two days, I simply made an HTTP service that emulates the backend interface.

It can do the following functions:

    1. It can create an HTTP local service
    2. It can simulate multiple requests from the backend, such as GET, post, put, delete
    3. JSON strings can be formatted
    4. You can verify the validity of the requested parameters

... And so on, usually in the back-end interface is not written well before, before and after the end of the joint adjustment, can be used, it can make your late and the end of the joint adjustment smoother, reduce inconsistencies between the front and back. Its main interface is this:

The main interface is very simple, just a few buttons, you can modify the port number, open the HTTP service, where the service is created by Express. You can then manage all the interfaces you have impersonated, all of which are stored in a local file. The interface for adding interfaces is as follows:

The URL here is localhost:8080/a/b/c, you can customize any structure, no longer need to create the corresponding folder. Parameters can also be multiple, return value, currently only a successful default return, the subsequent version will make conditional judgment return and other functions.

The management interface is as follows:

Management interface is relatively simple, mainly is the modification, deletion and preview function. The preview is to open the address with the local default browser.

A new JSON format verification feature is added here:

Later we can also be packaged JS and less functions are integrated into, basically, nodejs, electron to the infinite possibilities of the web.

Mock system:

Http://www.lovewebgames.com/app/mock/mock.exe

Http://www.react-cn.com/app/mock/mock.exe

Http://www.react-cn.com/app/mock/mock.rar

The GitHub address for this project is: Https://github.com/tianxiangbing/mock

The network download stuck when I packaged the electron, you can go to GitHub to load https://github.com/electron/electron/ Releases compress the package and copy it to the. Electron folder of the user directory, and then modify the package command to match the compression package:

Electron-packager. Mock--electron-version=0.37. 8 --asar.unpack=protocol-link.html--overwrite--platform=win32--arch=x64--icon=src/icon/favicon.ico-- out =out  --version-string. filedescription='mock' --version-string. Productname='mock'

For cross-domain issues, you can use the Nginx proxy.

Using electron to develop a H5 client application create HTTP service mock backend interface mock

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.