2016-06-07 03:45:30 +03:00
|
|
|
package request
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/url"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
exampleTokenA = "A"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ExampleHeaderExtractor() {
|
|
|
|
req := makeExampleRequest("GET", "/", map[string]string{"Token": exampleTokenA}, nil)
|
|
|
|
tokenString, err := HeaderExtractor{"Token"}.ExtractToken(req)
|
|
|
|
if err == nil {
|
|
|
|
fmt.Println(tokenString)
|
|
|
|
} else {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2023-06-21 13:39:55 +03:00
|
|
|
// Output: A
|
2016-06-07 03:45:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleArgumentExtractor() {
|
|
|
|
req := makeExampleRequest("GET", "/", nil, url.Values{"token": {extractorTestTokenA}})
|
|
|
|
tokenString, err := ArgumentExtractor{"token"}.ExtractToken(req)
|
|
|
|
if err == nil {
|
|
|
|
fmt.Println(tokenString)
|
|
|
|
} else {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2023-06-21 13:39:55 +03:00
|
|
|
// Output: A
|
2016-06-07 03:45:30 +03:00
|
|
|
}
|