首先需要beego框架的环境,若未安装,或者版本太老不具有api功能,请先更新或安装此篇。
1.安装好beego环境
2.利用bee api创建
打开doc窗口,进入到项目src目录下。即root。
bee api基本语法
usage: bee api [appname]
create an api application base on beego framework
bee api [appname] [-tables=""] [-driver=mysql] [-conn=root:@tcp(127.0.0.1:3306)/
test]
-tables: a list of table names separated by ',', default is empty, indicating all tables
-driver: [mysql | postgres | sqlite], the default is mysql
-conn: the connection string used by the driver, the default is ''
e.g. for mysql: root:@tcp(127.0.0.1:3306)/test
e.g. for postgres: postgres://postgres:postgres@127.0.0.1:5432/postgres
在doc下输入命令
bee api hello -conn=root:ro

本文介绍了如何在已有的beego环境中通过bee api命令来创建API框架。首先确保beego环境安装正确且版本支持API功能。接着在项目src目录下,使用bee api命令创建API,并给出基本语法。生成的API包括了各表的CRUD操作,可按需求进行定制。
最低0.47元/天 解锁文章
1008

被折叠的 条评论
为什么被折叠?



