appsettings.json 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. {
  2. "Sers": {
  3. /* 通讯层配置 */
  4. "CL": {
  5. /* 共用配置,子项共用,覆写子项未指定的配置 */
  6. "Config": {
  7. /* 请求超时时间(单位ms,默认60000) */
  8. "requestTimeoutMs": 60000,
  9. /* 后台处理消息的线程个数(单位个,默认2) */
  10. "workThreadCount":1,
  11. //HeartBeat
  12. /* 心跳检测时间间隔(单位ms,默认10000,若指定为0则不进行心跳检测) */
  13. "heartBeatIntervalMs": 10000,
  14. /* 心跳检测超时时间(单位ms,默认30000) */
  15. "heartBeatTimeoutMs": 30000,
  16. /* 心跳检测失败重试次数(单位次,默认10) */
  17. "heartBeatRetryCount": 10,
  18. /* 连接秘钥,用以验证连接安全性。服务端和客户端必须一致 */
  19. "secretKey": "SersCL"
  20. },
  21. /* one conn is one channel.can be multiable */
  22. "Server": [
  23. {
  24. // Socket.Iocp
  25. /* (x.1) type - Iocp */
  26. /* the class of Builder in assemblyFile */
  27. "className": "Sers.CL.Socket.Iocp.OrganizeServerBuilder",
  28. /* (x.2) conn config */
  29. /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sersms.com"。*/
  30. //"host": "127.0.0.1",
  31. /* 服务端 监听端口号。例如: 4501 */
  32. "port": 4501
  33. }
  34. ]
  35. },
  36. /* LocalApiService 配置,可不指定 */
  37. "LocalApiService": {
  38. /* 后台服务的线程个数(单位个,默认0,代表不开启服务)*/
  39. "workThreadCount": 4,
  40. /* 超时时间,若不指定则后台任务永不超时。(主动关闭超过此时间的任务,实际任务强制关闭的时间会在1倍超时时间到2倍超时时间内)。单位:ms。*/
  41. //"timeout_ms": 10000,
  42. /* 是否 输出本地Api的调用信息到(ApiTrace)Log文件。默认:false */
  43. "PrintTrace": false,
  44. /* 静态文件映射器。映射站点静态文件,可多个,可不指定 */
  45. "//StaticFileMap": [
  46. {
  47. /* api路由前缀,例如 "/demo/ui/*" */
  48. "route": "/demo/ui/*",
  49. /* api描述,静态文件描述 */
  50. "apiName": "demo站点静态文件",
  51. /* 静态文件路径。可为相对路径或绝对路径。若未指定存在的文件夹则默认为当前目录下的wwwroot文件夹。demo:"wwwroot/demo" */
  52. "staticFileDirectory": "wwwroot/demo",
  53. /* 额外静态文件类型映射配置的文件路径(mappings.json),例如"wwwroot/mappings.json"。若不指定(或指定的文件不存在)则不添加额外文件类型映射配置 */
  54. "ContentTypeMapFile": "mappings.json"
  55. }
  56. ],
  57. /* 默认站点名称,可多个,可不指定 */
  58. //"apiStationNames": [ "demo" ],
  59. /* Api加载器配置 */
  60. "ApiLoaders": [
  61. {
  62. //(通过反射从此包中获取要加载的api)
  63. /* 在此Assembly中查找服务(如 App.StationDemo.Station.dll)(assembly、assemblyFile、assemblyName 指定任一即可) */
  64. "assemblyFile": "Did.SersLoader.Demo.dll",
  65. /* ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  66. "apiStationName": "demo"
  67. },
  68. {
  69. /* ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  70. "apiStationName": "_robot_",
  71. /* 在此Assembly中查找服务(如 App.StationDemo.Station.dll)(assembly、assemblyFile、assemblyName 指定任一即可) */
  72. "assemblyFile": "App.Robot.Station.dll"
  73. }
  74. ],
  75. //调用api前的事件,可不指定
  76. "//BeforeCallApi": [
  77. {
  78. //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  79. "className": "Bearer",
  80. /* 验证at接口的地址 */
  81. "api_verifyAt": "/AuthCenter/account/verifyAt",
  82. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  83. "api_httpMethod": "POST"
  84. },
  85. {
  86. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  87. "className": "AccountInCookie",
  88. "account": [
  89. {
  90. "userToken": "admin_123456",
  91. //"CallerSource": "Internal",
  92. "userInfo": {
  93. "name": "超级管理员",
  94. "入口": "Gover网关"
  95. }
  96. }
  97. ]
  98. }
  99. ]
  100. },
  101. /* ServiceStation配置,可不指定 */
  102. "ServiceStation": {
  103. /* 自动上报cpu Usage。不指定则不上报 */
  104. "//UsageReporter": {
  105. /* 上报时间间隔(单位:秒) */
  106. "intervalSecond": 2
  107. },
  108. /* serviceStation站点信息 */
  109. "serviceStationInfo": {
  110. /* 服务站点名称 */
  111. "serviceStationName": "ServiceCenter",
  112. /* 服务站点版本信息,若不指定则为入口链接库的版本号 */
  113. //"stationVersion": "2.1.1",
  114. /* [json]服务站点额外信息,可不指定 */
  115. "info": null
  116. }
  117. },
  118. /* ServiceCenter 配置,可不指定 */
  119. "ServiceCenter": {
  120. /* 是否 输出Api注册事件到(Info)Log文件。默认:true */
  121. "ApiRegistEvent_Print": true,
  122. /* api路由管理方式,可不指定。可为:"RESTful","IgnoreHttpMethod"。若不指定或未指定有效值,则默认为"RESTful" */
  123. //"ApiRouteType": "IgnoreHttpMethod",
  124. //调用api前的事件,可不指定
  125. "BeforeCallApi": [
  126. {
  127. //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  128. //"className": "Bearer",
  129. /* 验证at接口的地址 */
  130. "api_verifyAt": "/AuthCenter/account/verifyAt",
  131. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  132. "api_httpMethod": "POST"
  133. },
  134. {
  135. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  136. //"className": "AccountInCookie",
  137. "account": [
  138. {
  139. "userToken": "admin_123456",
  140. //"CallerSource": "Internal",
  141. "userInfo": {
  142. "name": "超级管理员",
  143. "入口": "Gover网关"
  144. }
  145. }
  146. ]
  147. }
  148. ]
  149. },
  150. /* 网关配置(同目录下可以指定mappings.json文件) ,可不指定 */
  151. "Gateway": {
  152. /* Rpc配置,可不指定 */
  153. "Rpc": {
  154. /* 网关转发的请求中的rpc 信息中的 CallerSource。(暗指调用来源,默认"OutSide") */
  155. //"CallerSource": "OutSide"
  156. },
  157. "WebHost": {
  158. /* url,可多个 */
  159. "urls": [ "http://*:4580" ],
  160. /* http回应中的默认Content-Type。若不指定则默认为 "application/json; charset="+Serialization.Instance.charset */
  161. "//ResponseDefaultContentType": "application/json; charset=UTF-8",
  162. /* 静态文件路径。可为相对路径或绝对路径。若为空字符串则默认为当前目录下的wwwroot文件夹。若不指定(null)则不映射静态文件。 */
  163. "wwwroot": ""
  164. },
  165. //调用api前的事件,可不指定
  166. "BeforeCallApi": [
  167. {
  168. //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  169. //"className": "Bearer",
  170. /* 验证at接口的地址 */
  171. "api_verifyAt": "/AuthCenter/account/verifyAt",
  172. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  173. "api_httpMethod": "POST"
  174. },
  175. {
  176. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  177. "className": "AccountInCookie",
  178. "account": [
  179. {
  180. "userToken": "admin_123456",
  181. "CallerSource": "Internal",
  182. "userInfo": {
  183. "name": "Gover管理员",
  184. "入口": "Gover网关"
  185. }
  186. }
  187. ]
  188. }
  189. ],
  190. /* 服务限流配置,可不指定 */
  191. "rateLimit": [
  192. {
  193. /* 服务限流key,标识一个限流服务,必须唯一 */
  194. "rateLimitKey": "rate",
  195. /* 固定时间窗口限流。在单位时间(msInterval)内限制最大请求数量为reqLimit。超出数量的请求将被拒绝 */
  196. "rateLimitType": "FixedWindow",
  197. /* 单位时间内最大请求数量(个)*/
  198. "reqLimit": 100000,
  199. /* 单位时间长度(单位:ms)*/
  200. "msInterval": 1000
  201. }
  202. ]
  203. }
  204. },
  205. /* Vit工具配置,可不指定 */
  206. "Vit": {
  207. /* 日志配置,可不指定 */
  208. "Logger": {
  209. /* print the log to console. default:false */
  210. "PrintToConsole": true
  211. },
  212. /* 序列化配置,可不指定 */
  213. "Serialization": {
  214. /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */
  215. "Encoding": "UTF8",
  216. /* 时间序列化格式。可不指定,默认 "yyyy-MM-dd HH:mm:ss" */
  217. "DateTimeFormat": "yyyy-MM-dd HH:mm:ss"
  218. },
  219. "Kestrel": {
  220. /* the maximum allowed size of any request body in bytes. When set to null, the maximum request body size is unlimited. */
  221. "//MaxRequestBodySize": 100000000
  222. }
  223. }
  224. }