Using mins can be within five seconds (excluding download file time ...) Build a simple RESTful resource server.
Get ready
First download mins:
wget https://github.com/chenhg5/mins/releases/download/0.0.2/mins_mac -O mins
Because I am under Mac system, so download binary files corresponding to Mac. Corresponding system can download the corresponding version, download link: https://github.com/chenhg5/mi ...
Download OK, you can choose to put the binary file into the environment path. Need to execute permissions for mins:
chmod +x mins
Next, you need to write a configuration file Config.ini, which reads as follows:
[server]port = 4006[database]addr = localhostport = 3306user = rootpassword = rootdatabase = example
Example is the corresponding MySQL resource database, which has a users table.
Start
Then start the mins and it's done.
./mins -c ./config.ini
Experience
Then we add a data to the users table in example:
curl -X POST \ http://localhost:4006/resource/users \ -F name=jack \ -F sex=0
You can see that the database adds a new piece of data:
This data can then be found:
curl -X GET http://localhost:4006/resource/users/id/1{"code":200, "msg":"ok", "data": {"id":1,"name":"jack","sex":0}}
modifying data
curl -X PUT http://localhost:4006/resource/users/id/1 -F name=Mick
Delete data
curl -X DELETE http://localhost:4006/resource/users/id/1
static files
In addition to the resource additions and deletions, mins also built a static file server, through mins can access the current path of static files, such as html,css,image files.
Performance
With the development of Golang's Fasthttp network library, the performance is naturally great.