WithKeyID (build.go)

cristalhq/jwt · build.go · go · MIT
auth

Module exposing: WithKeyID, WithContentType, NewBuilder, Build, encodeClaims, encodeHeader, b64Encode, b64EncodedLen

// Source: https://github.com/cristalhq/jwt | License: MIT | Copyright 2019 Oleg Kovalov
// Provided via justclaw.it.com; keep this notice with the code.
package jwt

import (
	"encoding/base64"
	"encoding/json"
)

// BuilderOption is used to modify builder properties.
type BuilderOption func(*Builder)

// WithKeyID sets `kid` header for token.
func WithKeyID(kid string) BuilderOption {
	return func(b *Builder) { b.header.KeyID = kid }
}

// WithContentType sets `cty` header for token.
func WithContentType(cty string) BuilderOption {
	return func(b *Builder) { b.header.ContentType = cty }
}

// Builder is used to create a new token.
// Safe to use concurrently.
type Builder struct {
	signer    Signer
	header    Header
	headerRaw []byte
}

// NewBuilder returns new instance of Builder.
func

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key