appsettings.json 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. {
  2. "Sers": {
  3. /* 通讯层配置 */
  4. "CL": {
  5. /* one conn is one channel.can be multiable */
  6. "Client": [
  7. {
  8. // Socket.Iocp
  9. /* (x.1) type - Iocp */
  10. /* the class of builder in assemblyFile */
  11. "className": "Sers.CL.Socket.Iocp.OrganizeClientBuilder",
  12. /* (x.2) conn config */
  13. /* 服务端 host地址。例如: "127.0.0.1"、"sers.cloud" */
  14. "host": "127.0.0.1",
  15. /* 服务端 监听端口号。例如: 4501 */
  16. "port": 4501,
  17. //HeartBeat
  18. /* 心跳检测时间间隔(单位ms,默认10000,若指定为0则不进行心跳检测) */
  19. "heartBeatIntervalMs": 10000,
  20. /* 心跳检测超时时间(单位ms,默认30000) */
  21. "heartBeatTimeoutMs": 30000,
  22. /* 心跳检测失败重试次数(单位次,默认10) */
  23. "heartBeatRetryCount": 10,
  24. /* 连接秘钥,用以验证连接安全性。服务端和客户端必须一致 */
  25. "secretKey": "SersCL"
  26. }
  27. ]
  28. },
  29. // RpcData序列化模式。可不指定。默认为Text。
  30. // 可为 Newtonsoft、Text、BytePointor。
  31. // 效率依次递增。BytePointor 序列化为二进制数据而不是json字符串。
  32. "RpcDataSerializeMode": "Text",
  33. /* ServiceStation配置,可不指定 */
  34. "ServiceStation": {
  35. /* serviceStation站点信息 */
  36. "serviceStationInfo": {
  37. "serviceStationName": "Gateway"
  38. }
  39. },
  40. /* 网关配置 */
  41. "Gateway": {
  42. /* Rpc配置,可不指定 */
  43. "Rpc": {
  44. /* 网关转发的请求中的rpc 信息中的 CallerSource。(暗指调用来源,默认"OutSide") */
  45. //"CallerSource": "OutSide"
  46. },
  47. "WebHost": {
  48. /* url,可多个 */
  49. "urls": [ "http://*:4582" ],
  50. /* 是否允许跨域访问,默认true */
  51. "allowAnyOrigin": true,
  52. /* 把请求的ip地址、端口号复制到请求头中的前缀。若不指定则不复制。 */
  53. "prefixOfCopyIpToHeader": "Sers-Gateway-",
  54. /* http回应中的默认Content-Type。若不指定则默认为 "application/json; charset="+Serialization.Instance.charset */
  55. "//ResponseDefaultContentType": "application/json; charset=UTF-8",
  56. /* 映射静态文件。若不指定则不映射静态文件 */
  57. "//staticFiles": {
  58. /* 请求路径(可不指定)。demo:"/file/static"。The relative request path that maps to static resources */
  59. //"requestPath": "/file",
  60. /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则为默认路径(wwwroot)。demo:"wwwroot/demo" */
  61. //"rootPath": "wwwroot",
  62. /* 默认页面(可不指定)。An ordered list of file names to select by default. List length and ordering may affect performance */
  63. //"defaultFileNames": [],
  64. /* 是否可浏览目录(default false)。Enables directory browsing */
  65. //"useDirectoryBrowser": false,
  66. /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
  67. "contentTypeMapFile": "contentTypeMap.json",
  68. /* 回应静态文件时额外添加的http回应头。可不指定。 */
  69. "responseHeaders": {
  70. //设置浏览器静态文件缓存3600秒
  71. "Cache-Control": "public,max-age=3600"
  72. }
  73. }
  74. },
  75. //调用api前的事件,可不指定
  76. "BeforeCallApi": [
  77. {
  78. /* 在此Assembly中加载类 */
  79. "assemblyFile": "Sers.Core.dll",
  80. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  81. //"className": "Bearer",
  82. //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  83. /* 验证at接口的地址 */
  84. "api_verifyAt": "/AuthCenter/account/verifyAt",
  85. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  86. "api_httpMethod": "POST"
  87. },
  88. {
  89. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  90. //"className": "AccountInCookie",
  91. "account": [
  92. {
  93. "userToken": "admin_123456",
  94. //"CallerSource": "Internal",
  95. "userInfo": {
  96. "name": "超级管理员",
  97. "入口": "Gover网关"
  98. }
  99. }
  100. ]
  101. }
  102. ],
  103. /* 服务限流配置,可不指定 */
  104. "rateLimit": [
  105. {
  106. /* 服务限流key,标识一个限流服务,必须唯一 */
  107. "rateLimitKey": "rate",
  108. /* 固定时间窗口限流。在单位时间(msInterval)内限制最大请求数量为reqLimit。超出数量的请求将被拒绝 */
  109. "rateLimitType": "FixedWindow",
  110. /* 单位时间内最大请求数量(个)*/
  111. "reqLimit": 100000,
  112. /* 单位时间长度(单位:ms)*/
  113. "msInterval": 1000
  114. }
  115. ]
  116. }
  117. },
  118. /* Vit工具配置,可不指定 */
  119. "Vit": {
  120. /* 日志配置,可不指定 */
  121. "Logger": {
  122. /* print the log to Log/*.txt default:true */
  123. "PrintToTxt": true,
  124. /* print the log to console. default:false */
  125. "PrintToConsole": true
  126. },
  127. /* 队列模式,可不指定。可为 BlockingCollection(默认)、 ConsumerCache_BlockingCollection(高性能) */
  128. "ConsumerMode": "BlockingCollection",
  129. /* 序列化配置,可不指定 */
  130. "Serialization": {
  131. /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */
  132. "Encoding": "UTF8",
  133. /* 时间序列化格式。可不指定,默认 "yyyy-MM-dd HH:mm:ss" */
  134. "DateTimeFormat": "yyyy-MM-dd HH:mm:ss"
  135. },
  136. "//Kestrel": {
  137. /* (int64) the maximum allowed size of any request body in bytes. When set to null, the maximum request body size is unlimited. */
  138. "MaxRequestBodySize": 2000000000,
  139. /* (int32) A limit on the length of individual form values. Forms containing values that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
  140. "ValueLengthLimit": 2000000000,
  141. /* (int64) A limit for the length of each multipart body. Forms sections that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
  142. "MultipartBodyLengthLimit": 2000000000
  143. }
  144. }
  145. }