Skip to content

Commit 37df567

Browse files
gabygemini-code-assist[bot]
authored andcommitted
📒 docs: Ensure all exported elements are documented (gofiber#3752)
* docs: clarify short go doc comments * Update register.go Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 9ed4bff commit 37df567

39 files changed

Lines changed: 180 additions & 51 deletions

app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,7 @@ func (app *App) Test(req *http.Request, config ...TestConfig) (*http.Response, e
11761176

11771177
type disableLogger struct{}
11781178

1179+
// Printf implements the fasthttp Logger interface and discards log output.
11791180
func (*disableLogger) Printf(string, ...any) {
11801181
}
11811182

bind.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var bindPool = sync.Pool{
3030
},
3131
}
3232

33-
// Bind struct
33+
// Bind provides helper methods for binding request data to Go values.
3434
type Bind struct {
3535
ctx Ctx
3636
dontHandleErrs bool
@@ -331,6 +331,8 @@ func (b *Bind) Body(out any) error {
331331
return ErrUnprocessableEntity
332332
}
333333

334+
// All binds values from URI params, the request body, the query string,
335+
// headers, and cookies into the provided struct in precedence order.
334336
func (b *Bind) All(out any) error {
335337
outVal := reflect.ValueOf(out)
336338
if outVal.Kind() != reflect.Ptr || outVal.Elem().Kind() != reflect.Struct {

binder/binder.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ var MsgPackBinderPool = sync.Pool{
7171
},
7272
}
7373

74+
// GetFromThePool retrieves a binder from the provided sync.Pool and panics if
75+
// the stored value cannot be cast to the requested type.
7476
func GetFromThePool[T any](pool *sync.Pool) T {
7577
binder, ok := pool.Get().(T)
7678
if !ok {
@@ -80,6 +82,7 @@ func GetFromThePool[T any](pool *sync.Pool) T {
8082
return binder
8183
}
8284

85+
// PutToThePool returns the binder to the provided sync.Pool.
8386
func PutToThePool[T any](pool *sync.Pool, binder T) {
8487
pool.Put(binder)
8588
}

binder/cbor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ func (b *CBORBinding) Reset() {
2424
b.CBORDecoder = nil
2525
}
2626

27+
// UnimplementedCborMarshal panics to signal that a CBOR marshaler must be
28+
// configured before CBOR support can be used.
2729
func UnimplementedCborMarshal(_ any) ([]byte, error) {
2830
panic("Must explicitly setup CBOR, please check docs: https://docs.gofiber.io/next/guide/advance-format#cbor")
2931
}
3032

33+
// UnimplementedCborUnmarshal panics to signal that a CBOR unmarshaler must be
34+
// configured before CBOR support can be used.
3135
func UnimplementedCborUnmarshal(_ []byte, _ any) error {
3236
panic("Must explicitly setup CBOR, please check docs: https://docs.gofiber.io/next/guide/advance-format#cbor")
3337
}

binder/header.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"github.com/valyala/fasthttp"
66
)
77

8-
// v is the header binder for header request body.
8+
// HeaderBinding is the binder implementation used to populate values from HTTP headers.
99
type HeaderBinding struct {
1010
EnableSplitting bool
1111
}

binder/mapping.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func equalFieldType(out any, kind reflect.Kind, key, aliasTag string) bool {
288288
return false
289289
}
290290

291-
// Get content type from content type header
291+
// FilterFlags returns the media type value by trimming any parameters from a Content-Type header.
292292
func FilterFlags(content string) string {
293293
for i, char := range content {
294294
if char == ' ' || char == ';' {

binder/msgpack.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ func (b *MsgPackBinding) Reset() {
2424
b.MsgPackDecoder = nil
2525
}
2626

27+
// UnimplementedMsgpackMarshal panics to signal that a Msgpack marshaler must
28+
// be configured before MsgPack support can be used.
2729
func UnimplementedMsgpackMarshal(_ any) ([]byte, error) {
2830
panic("Must explicit setup Msgpack, please check docs: https://docs.gofiber.io/next/guide/advance-format#msgpack")
2931
}
3032

33+
// UnimplementedMsgpackUnmarshal panics to signal that a Msgpack unmarshaler
34+
// must be configured before MsgPack support can be used.
3135
func UnimplementedMsgpackUnmarshal(_ []byte, _ any) error {
3236
panic("Must explicit setup Msgpack, please check docs: https://docs.gofiber.io/next/guide/advance-format#msgpack")
3337
}

binder/uri.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package binder
22

3-
// uriBinding is the URI binder for URI parameters.
3+
// URIBinding is the binder implementation for populating values from route parameters.
44
type URIBinding struct{}
55

66
// Name returns the binding name.

client/request.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,18 @@ type pair struct {
134134
v []string
135135
}
136136

137+
// Len implements sort.Interface and reports the number of tracked keys.
137138
func (p *pair) Len() int {
138139
return len(p.k)
139140
}
140141

142+
// Swap implements sort.Interface and swaps the entries at the provided indices.
141143
func (p *pair) Swap(i, j int) {
142144
p.k[i], p.k[j] = p.k[j], p.k[i]
143145
p.v[i], p.v[j] = p.v[j], p.v[i]
144146
}
145147

148+
// Less implements sort.Interface and orders entries lexicographically by key.
146149
func (p *pair) Less(i, j int) bool {
147150
return p.k[i] < p.k[j]
148151
}

ctx.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ type DefaultCtx struct {
7070
matched bool // Non use route matched
7171
}
7272

73-
// TLSHandler object
73+
// TLSHandler hosts the callback hooks Fiber invokes while negotiating TLS
74+
// connections, including optional client certificate lookups.
7475
type TLSHandler struct {
7576
clientHelloInfo *tls.ClientHelloInfo
7677
}
@@ -149,11 +150,7 @@ func (*DefaultCtx) Done() <-chan struct{} {
149150
return nil
150151
}
151152

152-
// If Done is not yet closed, Err returns nil.
153-
// If Done is closed, Err returns a non-nil error explaining why:
154-
// context.DeadlineExceeded if the context's deadline passed,
155-
// or context.Canceled if the context was canceled for some other reason.
156-
// After Err returns a non-nil error, successive calls to Err return the same error.
153+
// Err mirrors context.Err, returning nil until cancellation and then the terminal error value.
157154
//
158155
// Due to current limitations in how fasthttp works, Err operates as a nop.
159156
// See: https://github.com/valyala/fasthttp/issues/965#issuecomment-777268945

0 commit comments

Comments
 (0)