appsettings.json 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. {
  2. /* asp.net core 原始web服务配置 */
  3. "server": {
  4. "urls": [ "http://localhost:4513" ]
  5. },
  6. "Logging": {
  7. "LogLevel": {
  8. "Default": "Warning"
  9. }
  10. },
  11. "AllowedHosts": "*",
  12. "Sers": {
  13. /* 通讯层配置 */
  14. "CL": {
  15. /* one conn is one channel.can be multiable */
  16. "Client": [
  17. {
  18. // Socket.Iocp
  19. /* (x.1) type - Iocp */
  20. /* the class of builder in assemblyFile */
  21. "className": "Sers.CL.Socket.Iocp.OrganizeClientBuilder",
  22. /* (x.2) conn config */
  23. /* 服务端 host地址。例如: "127.0.0.1"、"sersms.com" */
  24. "host": "127.0.0.1",
  25. /* 服务端 监听端口号。例如: 4501 */
  26. "port": 4501,
  27. /* 连接秘钥,用以验证连接安全性。服务端和客户端必须一致 */
  28. "secretKey": "SersCL"
  29. }
  30. ]
  31. },
  32. /* LocalApiService 配置,可不指定 */
  33. "LocalApiService": {
  34. /* 后台服务的线程个数(单位个,默认0,代表不开启服务) */
  35. "workThreadCount": 4,
  36. /* 超时时间,若不指定则后台任务永不超时。(主动关闭超过此时间的任务,实际任务强制关闭的时间会在1倍超时时间到2倍超时时间内)。单位:ms。*/
  37. //"timeout_ms": 10000,
  38. /* 是否 输出本地Api的调用信息到(ApiTrace)Log文件。默认:false */
  39. "PrintTrace": false,
  40. /* 静态文件映射器。映射站点静态文件,可多个,可不指定 */
  41. "//staticFiles": [
  42. {
  43. /* api路由前缀,例如 "/demo/ui/*" */
  44. "route": "/demo/ui/*",
  45. /* api描述,静态文件描述 */
  46. "apiName": "demo站点静态文件",
  47. /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo" */
  48. "rootPath": "wwwroot/demo",
  49. /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"mappings.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
  50. "contentTypeMapFile": "mappings.json",
  51. /* 回应静态文件时额外添加的http回应头。可不指定。 */
  52. "responseHeaders": {
  53. //设置浏览器静态文件缓存3600秒
  54. "Cache-Control": "public,max-age=3600"
  55. }
  56. }
  57. ],
  58. /* 默认站点名称,可多个,可不指定 */
  59. //"apiStationNames": [ "demo" ],
  60. /* Api加载器配置 */
  61. "//ApiLoaders": [
  62. {
  63. /* 在此Assembly中查找api加载器(如 Sers.Core.dll 、Sers.NetcoreLoader.dll 、 Sers.Serslot.dll ) */
  64. //"loader_assemblyFile": "Sers.Core.dll",
  65. /* 加载器的类名,可为 Sers.SersLoader.ApiLoader 、 Sers.NetcoreLoader.ApiLoader、 Sers.Serslot.ApiLoader 等。若不指定则默认为"Sers.SersLoader.ApiLoader" */
  66. //"loader_className": "Sers.SersLoader.ApiLoader",
  67. //(通过反射从此包中获取要加载的api)
  68. /* 在此Assembly中查找服务(如 Did.SersLoader.Demo.dll)(assembly、assemblyFile、assemblyName 指定任一即可) */
  69. "assemblyFile": "Did.SersLoader.Demo.dll",
  70. /* 在此Assembly中查找服务(如 Did.SersLoader.Demo)(assembly、assemblyFile、assemblyName 指定任一即可) */
  71. //"assemblyName": "Did.SersLoader.Demo",
  72. /* 强制指定ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  73. //"apiStationName_Force": "",
  74. /* ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  75. "apiStationName": "demo"
  76. /* 强制路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低: routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix) */
  77. //"routePrefix_Force": "",
  78. /* 路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低: routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix ) */
  79. //"routePrefix": ""
  80. }
  81. ],
  82. //调用api前的事件,可不指定
  83. "//BeforeCallApi": [
  84. {
  85. //Bearer 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  86. "className": "Bearer",
  87. /* 验证at接口的地址 */
  88. "api_verifyAt": "/AuthCenter/account/verifyAt",
  89. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  90. "api_httpMethod": "POST"
  91. },
  92. {
  93. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  94. "className": "AccountInCookie",
  95. "account": [
  96. {
  97. "userToken": "admin_123456",
  98. //"CallerSource": "Internal",
  99. "userInfo": {
  100. "name": "超级管理员",
  101. "入口": "Gover网关"
  102. }
  103. }
  104. ]
  105. }
  106. ]
  107. },
  108. /* ServiceStation配置,可不指定 */
  109. "ServiceStation": {
  110. /* 自动上报cpu Usage。不指定则不上报 */
  111. "//UsageReporter": {
  112. /* 上报时间间隔(单位:秒) */
  113. "intervalSecond": 2
  114. },
  115. /* 服务中心注册配置。在向服务中心注册站点前 是否打印(Logger.Info)请求参数。默认:false */
  116. "StationRegist_PrintRegistArg": false,
  117. /* serviceStation站点信息 */
  118. "serviceStationInfo": {
  119. "serviceStationName": "SerslotDemo",
  120. /* 服务站点版本信息,若不指定则为入口链接库的版本号 */
  121. //"stationVersion": "1.1.9.0",
  122. /* [json]服务站点额外信息,可不指定 */
  123. "info": null
  124. }
  125. }
  126. },
  127. /* Vit工具配置,可不指定 */
  128. "Vit": {
  129. /* 日志配置,可不指定 */
  130. "Logger": {
  131. /* print the log to console. default:false */
  132. "PrintToConsole": true
  133. },
  134. /* 序列化配置,可不指定 */
  135. "Serialization": {
  136. /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */
  137. "Encoding": "UTF8",
  138. /* 时间序列化格式。可不指定,默认 "yyyy-MM-dd HH:mm:ss" */
  139. "DateTimeFormat": "yyyy-MM-dd HH:mm:ss"
  140. }
  141. },
  142. "serslot": {
  143. /* 额外api。SsApiDesc格式。除了系统api外,可以指定额外api。若指定返回数据(reply),则直接返回数据;若不指定返回数据,则由host进行处理 */
  144. "//extApi": [
  145. { //为 SsApiDesc格式
  146. "description": "首页",
  147. //路由(可为泛接口,如 "/a/*" )
  148. "route": "/index.html",
  149. //扩展配置(json)
  150. "extendConfig": {
  151. //请求方式,若不指定则默认支持所有方式(demo: POST、GET、DELETE、PUT等)
  152. "httpMethod": "GET",
  153. //返回数据(可为数值、字符串、对象、数组)。若不指定,则由host进行处理
  154. "reply": { "hello": "sers" },
  155. //系统生成的接口文字描述
  156. "sysDesc": "method:GET"
  157. }
  158. },
  159. {
  160. //路由(可为泛接口,如 "/a/*" )
  161. "route": "/*"
  162. }
  163. ]
  164. }
  165. }