Coding APIs
#
Create a file- Define a request(LoginReq) and responese(LoginReply) and a user-api service with a
POST
method, path/user/login
with theLoginReq
request andLoginReply
response.
#
Generate api services#
Use goctl to generate api files with .api definitions#
Use a Plugin in IntellijRight-click on the user.api
file, and then click to enter New
->Go Zero
->Api Code
, enter the target directory selection, that is, the target storage directory of the api source code, the default is the directory where user.api is located, select Click OK after finishing the list.
#
By KeymapOpen user.api, enter the editing area, use the shortcut key Command+N
(for macOS) or alt+insert
(for windows), select Api Code
, and also enter the directory selection pop-up window, after selecting the directory Just click OK.