export interface; -w 时自动监听没有content-type的html
This commit is contained in:
parent
069a4b95c2
commit
fa97cace29
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module apigo.cc/gojs/service
|
||||
go 1.24.0
|
||||
|
||||
require (
|
||||
apigo.cc/gojs v0.0.30
|
||||
apigo.cc/gojs v0.0.31
|
||||
apigo.cc/gojs/console v0.0.4
|
||||
apigo.cc/gojs/file v0.0.7
|
||||
apigo.cc/gojs/http v0.0.8
|
||||
|
||||
@ -290,8 +290,9 @@ func init() {
|
||||
onWatchLock.Unlock()
|
||||
}, "")
|
||||
s.SetOutFilter(func(in map[string]any, request *s.Request, response *s.Response, out any, logger *log.Logger) (newOut any, isOver bool) {
|
||||
if strings.HasPrefix(response.Header().Get("Content-Type"), "text/html") {
|
||||
contentType := response.Header().Get("Content-Type")
|
||||
outStr := u.String(out)
|
||||
if strings.HasPrefix(contentType, "text/html") || (contentType == "" && strings.Contains(outStr, "<html")) {
|
||||
if strings.Contains(outStr, "let _watchWS = null") {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
34
service.ts
34
service.ts
@ -55,7 +55,7 @@ function id(size?: number): string { return '' }
|
||||
function setTplFunc(fnList: Object): void { }
|
||||
function tpl(file: string, data: Object): string { return '' }
|
||||
|
||||
interface Config {
|
||||
export interface Config {
|
||||
// github.com/ssgo/s 的配置参数
|
||||
listen: string // 监听端口(|隔开多个监听)(,隔开多个选项)(如果不指定IP则监听在0.0.0.0,如果不指定端口则使用h2c协议监听在随机端口,80端口默认使用http协议,443端口默认使用https协议),例如 80,http|443|443:h2|127.0.0.1:8080,h2c
|
||||
ssl: Map<string, CertSet> // SSL证书配置,key为域名,value为cert和key的文件路径
|
||||
@ -134,24 +134,24 @@ interface Config {
|
||||
ipPrefix: string // discover服务发现时指定使用的IP网段,默认排除 172.17.(Docker)
|
||||
}
|
||||
|
||||
interface CertSet {
|
||||
export interface CertSet {
|
||||
certFile: string
|
||||
keyFile: string
|
||||
}
|
||||
|
||||
interface PoolConfig {
|
||||
export interface PoolConfig {
|
||||
min: number
|
||||
max: string
|
||||
idle: number
|
||||
}
|
||||
|
||||
interface LimiterConfig {
|
||||
export interface LimiterConfig {
|
||||
from: string
|
||||
time: number
|
||||
times: number
|
||||
}
|
||||
|
||||
interface RegisterOption {
|
||||
export interface RegisterOption {
|
||||
authLevel: number
|
||||
host: string
|
||||
method: string
|
||||
@ -167,7 +167,7 @@ interface RegisterOption {
|
||||
onClose: (params: RequestParams) => void
|
||||
}
|
||||
|
||||
interface RequestParams {
|
||||
export interface RequestParams {
|
||||
args: Object
|
||||
headers: Object
|
||||
request: Request
|
||||
@ -178,7 +178,7 @@ interface RequestParams {
|
||||
logger: Logger
|
||||
}
|
||||
|
||||
interface OnMessageParams {
|
||||
export interface OnMessageParams {
|
||||
type: string
|
||||
data: string | Object
|
||||
client: WSClient
|
||||
@ -186,7 +186,7 @@ interface OnMessageParams {
|
||||
logger: Logger
|
||||
}
|
||||
|
||||
interface WSClient {
|
||||
export interface WSClient {
|
||||
id: string
|
||||
read: () => WSMessage
|
||||
write: (data: any) => void
|
||||
@ -195,12 +195,12 @@ interface WSClient {
|
||||
close: () => void
|
||||
}
|
||||
|
||||
interface WSMessage {
|
||||
export interface WSMessage {
|
||||
type: string
|
||||
data: string | Object
|
||||
}
|
||||
|
||||
interface Session {
|
||||
export interface Session {
|
||||
set: (key: string | Object, value?: any) => void
|
||||
get: (...keys: string[]) => any | Object
|
||||
remove: (...keys: string[]) => void
|
||||
@ -208,7 +208,7 @@ interface Session {
|
||||
save: () => void
|
||||
}
|
||||
|
||||
interface Caller {
|
||||
export interface Caller {
|
||||
get(url: string, headers?: Object): Result
|
||||
head(url: string, headers?: Object): Result
|
||||
post(url: string, data: any, headers?: Object): Result
|
||||
@ -217,7 +217,7 @@ interface Caller {
|
||||
do(method: string, url: string, data: any, callback?: (data: string) => void, headers?: Object): Result
|
||||
}
|
||||
|
||||
interface Result {
|
||||
export interface Result {
|
||||
status: string
|
||||
statusCode: number
|
||||
headers: Object
|
||||
@ -226,7 +226,7 @@ interface Result {
|
||||
object(): Object
|
||||
}
|
||||
|
||||
interface CookieOption {
|
||||
export interface CookieOption {
|
||||
path: string
|
||||
domain: string
|
||||
expires: any
|
||||
@ -235,7 +235,7 @@ interface CookieOption {
|
||||
httpOnly: boolean
|
||||
}
|
||||
|
||||
interface Request {
|
||||
export interface Request {
|
||||
id: string
|
||||
proto: string
|
||||
scheme: string
|
||||
@ -264,7 +264,7 @@ interface Request {
|
||||
setUserID: (id: string) => void
|
||||
}
|
||||
|
||||
interface Response {
|
||||
export interface Response {
|
||||
id: string
|
||||
setStatus: (code: number) => void
|
||||
setCookie: (name: string, value: string, option?: CookieOption) => void
|
||||
@ -279,14 +279,14 @@ interface Response {
|
||||
end: (data: any) => void
|
||||
}
|
||||
|
||||
interface Logger {
|
||||
export interface Logger {
|
||||
debug: (message: string, info?: Object) => void
|
||||
info: (message: string, info?: Object) => void
|
||||
warn: (message: string, info?: Object) => void
|
||||
error: (message: string, info?: Object) => void
|
||||
}
|
||||
|
||||
interface UploadFile {
|
||||
export interface UploadFile {
|
||||
name: string
|
||||
size: number
|
||||
data: any
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user