# micro_service ## api/conf ### GET / return all configure, content from file `etc/conf.json` ```json { "dbs": { "data_center": { "uri": "postgres://postgres:123456@127.0.0.1:5432/cim_data_center", "default": true }, "base_map": { "uri": "postgres://postgres:123456@127.0.0.1:5432/cim_base_map", "default": false } }, "sqls": { "test": { "db": "data_center", "sql": "select :pa as pa, :pb as pb" }, "orders": { "db": "data_center", "sql": "select * from orders where id=:id::integer" }, "charts": { "sql": "select * from chart where id=:id" }, "names.all": { "sql": "select * from names" }, "names.insert": { "db": "data_center", "sql": "insert into names(id, name) values(:id, :name) returning id,name" } } } ``` ### GET /:path return `path` content, the path of the property to get, `a.b.c` GET /api/conf/dbs.data_center ```json { "uri": "postgres://postgres:123456@127.0.0.1:5432/cim_data_center", "default": true } ``` GET /api/conf/dbs.data_center.uri ```json "postgres://postgres:123456@127.0.0.1:5432/cim_data_center" ``` ### GET /:path/:key return `path` and `key`, `path` support `a.b.c` as json path, `key` as string. GET /api/sqls/name.all ```json { "sql": "select * from names" } ``` ### POST /:path/:key set `path` and `key`, if `path` is not exist, new `path` for conf. if `path` is exit, add or replace key for value. POST /api/conf/test.post/new.key
Content-Type:application/json ```json {"new.name":"new.value"} ``` response ```json { "path": "test.post", "key": "new.key", "value": { "new.name": "new.value" } } ``` conf file added ``` "test": { "post": { "new.key": { "new.name": "new.value" } } } ``` ### DELETE /:path/:key unset `path` and `key` from conf file ## api/db `key` from conf file's `sqls` ### GET /:key?pa=1&pb=2 exec `db` and `sql` from conf file. GET /api/db/test?pa=1&pb=2 ```json [{"pa":"1","pb":"2"}] ``` ### POST /:key POST /api/db/test
Content-Type:application/json ```json {"pa":1,"pb":2} ``` response ```json [ { "pa": 1, "pb": 2 } ] ```