feat: 新版 server 包 HTTP 基础实现
This commit is contained in:
20
utils/super/context.go
Normal file
20
utils/super/context.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package super
|
||||
|
||||
import "context"
|
||||
|
||||
func WithCancelContext(ctx context.Context) *CancelContext {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
return &CancelContext{
|
||||
Context: ctx,
|
||||
cancel: cancel,
|
||||
}
|
||||
}
|
||||
|
||||
type CancelContext struct {
|
||||
context.Context
|
||||
cancel func()
|
||||
}
|
||||
|
||||
func (c *CancelContext) Cancel() {
|
||||
c.cancel()
|
||||
}
|
||||
Reference in New Issue
Block a user