@@ -19,6 +19,7 @@ import (
19
19
"github.com/gogf/gf/v2/container/gtype"
20
20
"github.com/gogf/gf/v2/errors/gcode"
21
21
"github.com/gogf/gf/v2/errors/gerror"
22
+ "github.com/gogf/gf/v2/net/ghttp/internal/graceful"
22
23
"github.com/gogf/gf/v2/net/goai"
23
24
"github.com/gogf/gf/v2/net/gsvc"
24
25
"github.com/gogf/gf/v2/os/gcache"
34
35
instance string // Instance name of current HTTP server.
35
36
config ServerConfig // Server configuration.
36
37
plugins []Plugin // Plugin array to extend server functionality.
37
- servers []* gracefulServer // Underlying http.Server array.
38
+ servers []* graceful. Server // Underlying http.Server array.
38
39
serverCount * gtype.Int // Underlying http.Server number for internal usage.
39
40
closeChan chan struct {} // Used for underlying server closing event notification.
40
41
serveTree map [string ]interface {} // The route maps tree.
69
70
Method string // Handler method name.
70
71
Route string // Route URI.
71
72
Priority int // Just for reference.
72
- IsServiceHandler bool // Is service handler.
73
+ IsServiceHandler bool // Is a service handler.
73
74
}
74
75
75
76
// HandlerFunc is request handler function.
@@ -127,42 +128,41 @@ type (
127
128
128
129
const (
129
130
// FreePortAddress marks the server listens using random free port.
130
- FreePortAddress = ":0"
131
+ FreePortAddress = graceful . FreePortAddress
131
132
)
132
133
133
134
const (
134
- HeaderXUrlPath = "x-url-path" // Used for custom route handler, which does not change URL.Path.
135
- HookBeforeServe HookName = "HOOK_BEFORE_SERVE" // Hook handler before route handler/file serving.
136
- HookAfterServe HookName = "HOOK_AFTER_SERVE" // Hook handler after route handler/file serving.
137
- HookBeforeOutput HookName = "HOOK_BEFORE_OUTPUT" // Hook handler before response output.
138
- HookAfterOutput HookName = "HOOK_AFTER_OUTPUT" // Hook handler after response output.
139
- ServerStatusStopped ServerStatus = 0
140
- ServerStatusRunning ServerStatus = 1
141
- DefaultServerName = "default "
142
- DefaultDomainName = "default "
143
- HandlerTypeHandler HandlerType = "handler "
144
- HandlerTypeObject HandlerType = "object "
145
- HandlerTypeMiddleware HandlerType = "middleware"
146
- HandlerTypeHook HandlerType = "hook"
135
+ HeaderXUrlPath = "x-url-path" // Used for custom route handler, which does not change URL.Path.
136
+ HookBeforeServe HookName = "HOOK_BEFORE_SERVE" // Hook handler before route handler/file serving.
137
+ HookAfterServe HookName = "HOOK_AFTER_SERVE" // Hook handler after route handler/file serving.
138
+ HookBeforeOutput HookName = "HOOK_BEFORE_OUTPUT" // Hook handler before response output.
139
+ HookAfterOutput HookName = "HOOK_AFTER_OUTPUT" // Hook handler after response output.
140
+ DefaultServerName = "default"
141
+ DefaultDomainName = "default"
142
+ HandlerTypeHandler HandlerType = "handler "
143
+ HandlerTypeObject HandlerType = "object "
144
+ HandlerTypeMiddleware HandlerType = "middleware "
145
+ HandlerTypeHook HandlerType = "hook "
146
+ ServerStatusStopped = graceful . ServerStatusStopped
147
+ ServerStatusRunning = graceful . ServerStatusRunning
147
148
)
148
149
149
150
const (
150
- supportedHttpMethods = "GET,PUT,POST,DELETE,PATCH,HEAD,CONNECT,OPTIONS,TRACE"
151
- defaultMethod = "ALL"
152
- routeCacheDuration = time .Hour
153
- ctxKeyForRequest gctx.StrKey = "gHttpRequestObject"
154
- contentTypeXml = "text/xml"
155
- contentTypeHtml = "text/html"
156
- contentTypeJson = "application/json"
157
- contentTypeJavascript = "application/javascript"
158
- swaggerUIPackedPath = "/goframe/swaggerui"
159
- responseHeaderTraceID = "Trace-ID"
160
- responseHeaderContentLength = "Content-Length"
161
- specialMethodNameInit = "Init"
162
- specialMethodNameShut = "Shut"
163
- specialMethodNameIndex = "Index"
164
- defaultEndpointPort = 80
165
- noPrintInternalRoute = "internalMiddlewareServerTracing"
151
+ supportedHttpMethods = "GET,PUT,POST,DELETE,PATCH,HEAD,CONNECT,OPTIONS,TRACE"
152
+ defaultMethod = "ALL"
153
+ routeCacheDuration = time .Hour
154
+ ctxKeyForRequest gctx.StrKey = "gHttpRequestObject"
155
+ contentTypeXml = "text/xml"
156
+ contentTypeHtml = "text/html"
157
+ contentTypeJson = "application/json"
158
+ contentTypeJavascript = "application/javascript"
159
+ swaggerUIPackedPath = "/goframe/swaggerui"
160
+ responseHeaderTraceID = "Trace-ID"
161
+ specialMethodNameInit = "Init"
162
+ specialMethodNameShut = "Shut"
163
+ specialMethodNameIndex = "Index"
164
+ defaultEndpointPort = 80
165
+ noPrintInternalRoute = "internalMiddlewareServerTracing"
166
166
)
167
167
168
168
const (
0 commit comments