Skip to content

Commit e884c8a

Browse files
committed
add more comments
1 parent 8615c68 commit e884c8a

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

services/context/api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import (
2222
)
2323

2424
// APIContext is a specific context for API service
25+
// ATTENTION: This struct should never be manually constructed in routes/services,
26+
// it has many internal details which should be carefully prepared by the framework.
27+
// If it is abused, it would cause strange bugs like panic/resource-leak.
2528
type APIContext struct {
2629
*Base
2730

services/context/base.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ type BaseContextKeyType struct{}
2323

2424
var BaseContextKey BaseContextKeyType
2525

26+
// Base is the base context for all web handlers
27+
// ATTENTION: This struct should never be manually constructed in routes/services,
28+
// it has many internal details which should be carefully prepared by the framework.
29+
// If it is abused, it would cause strange bugs like panic/resource-leak.
2630
type Base struct {
2731
reqctx.RequestContext
2832

services/context/context.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ type Render interface {
3434
HTML(w io.Writer, status int, name templates.TplName, data any, templateCtx context.Context) error
3535
}
3636

37-
// Context represents context of a request.
37+
// Context represents context of a web request.
38+
// ATTENTION: This struct should never be manually constructed in routes/services,
39+
// it has many internal details which should be carefully prepared by the framework.
40+
// If it is abused, it would cause strange bugs like panic/resource-leak.
3841
type Context struct {
3942
*Base
4043

0 commit comments

Comments
 (0)