Skip to content

Commit b3d52c5

Browse files
committed
Added some more documentation, why types are not exported
1 parent 1bbb42b commit b3d52c5

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

claims.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import (
99
// Claims must just have a Valid method that determines
1010
// if the token is invalid for any supported reason
1111
type Claims interface {
12+
// Valid implements claim validation. The opts are function style options that can
13+
// be used to fine-tune the validation. The type used for the options is intentionally
14+
// un-exported, since its API and its naming is subject to change.
1215
Valid(opts ...validationOption) error
1316
}
1417

parser_option.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ func WithoutClaimsValidation() ParserOption {
3333
// WithLeeway returns the ParserOption for specifying the leeway window.
3434
func WithLeeway(d time.Duration) ParserOption {
3535
return func(p *Parser) {
36-
p.validationOptions = append(p.validationOptions, withLeewayValidator(d))
36+
p.validationOptions = append(p.validationOptions, withLeeway(d))
3737
}
3838
}

validator_option.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,25 @@ import "time"
44

55
// validationOption is used to implement functional-style options that modify the behavior of the parser. To add
66
// new options, just create a function (ideally beginning with With or Without) that returns an anonymous function that
7-
// takes a *ValidatorOptions type as input and manipulates its configuration accordingly.
7+
// takes a *validator type as input and manipulates its configuration accordingly.
8+
//
9+
// Note that this struct is (currently) un-exported, its naming is subject to change and will only be exported once
10+
// the API is more stable.
811
type validationOption func(*validator)
912

1013
// validator represents options that can be used for claims validation
14+
//
15+
// Note that this struct is (currently) un-exported, its naming is subject to change and will only be exported once
16+
// the API is more stable.
1117
type validator struct {
1218
leeway time.Duration // Leeway to provide when validating time values
1319
}
1420

15-
16-
// withLeewayValidator is an option to set the clock skew (leeway) windows
17-
func withLeewayValidator(d time.Duration) validationOption {
21+
// withLeeway is an option to set the clock skew (leeway) window
22+
//
23+
// Note that this function is (currently) un-exported, its naming is subject to change and will only be exported once
24+
// the API is more stable.
25+
func withLeeway(d time.Duration) validationOption {
1826
return func(v *validator) {
1927
v.leeway = d
2028
}

0 commit comments

Comments
 (0)