forked from golang-jwt/jwt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
encoder.go
35 lines (26 loc) · 886 Bytes
/
encoder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package jwt
import "io"
// Base64Encoding represents an object that can encode and decode base64. A
// common example is [encoding/base64.Encoding].
type Base64Encoding interface {
EncodeToString(src []byte) string
DecodeString(s string) ([]byte, error)
}
type StrictFunc[T Base64Encoding] func() T
type Stricter[T Base64Encoding] interface {
Strict() T
}
func DoStrict[S Base64Encoding, T Stricter[S]](x T) Base64Encoding {
return x.Strict()
}
// JSONMarshalFunc is a function type that allows to implement custom JSON
// encoding algorithms.
type JSONMarshalFunc func(v any) ([]byte, error)
// JSONUnmarshalFunc is a function type that allows to implement custom JSON
// unmarshal algorithms.
type JSONUnmarshalFunc func(data []byte, v any) error
type JSONDecoder interface {
UseNumber()
Decode(v any) error
}
type JSONNewDecoderFunc[T JSONDecoder] func(r io.Reader) T