Documentation
¶
Overview ¶
Package key encodes and parses JaWS request and session keys.
This package is a textual codec only. Successful parsing does not prove that a request or session is live or authorized, nor does it enforce request single-use or client binding; package github.com/linkdata/jaws owns those checks.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Key ¶
type Key uint64
Key identifies a JaWS request or session.
A zero Key is invalid and encodes as an empty string. Non-zero keys encode as base-32 text for use in JaWS URLs, HTML metadata and session cookies.
func Parse ¶
Parse parses a JaWS key prefix from its text form.
If s contains a slash, tail is the slash and everything after it. The returned key is zero if the prefix before tail is not a valid base-32 key.
Decoding is case-insensitive (base-32 'A' and 'a' both decode to 10), while Key.String and Append always emit lowercase, so a parsed uppercase prefix does not re-encode to its own text.
Example ¶
ExampleParse shows how a slash splits the key prefix from the trailing path.
package main
import (
"fmt"
"github.com/linkdata/jaws/lib/key"
)
func main() {
k, tail := key.Parse("2/noscript")
fmt.Printf("key=%v tail=%q\n", k, tail)
}
Output: key=2 tail="/noscript"