Documentation
¶
Index ¶
Constants ¶
View Source
const (
MaxBodySize = 256
)
Variables ¶
View Source
var (
ErrFailedToDecodeBody = errors.New("failed to decode body")
)
Functions ¶
This section is empty.
Types ¶
type ChallengeRequestBody ¶
type ChallengeRequestBody struct{}
func (ChallengeRequestBody) Encode ¶
func (b ChallengeRequestBody) Encode() []byte
type ChallengeResponseBody ¶
type ChallengeResponseBody struct {
// contains filtered or unexported fields
}
func DecodeChallengeResponseBody ¶
func DecodeChallengeResponseBody(data []byte) (ChallengeResponseBody, error)
func (ChallengeResponseBody) Encode ¶
func (b ChallengeResponseBody) Encode() []byte
type Challenger ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (Client) GetChallengeRequest ¶
func (Client) HandleChallengeResponse ¶
func (Client) HandleErrorResponse ¶
func (Client) HandleVerifiedResponse ¶
func (Client) IsErrorResponse ¶
type ErrorResponseBody ¶
type ErrorResponseBody struct {
// contains filtered or unexported fields
}
func DecodeErrorResponseBody ¶
func DecodeErrorResponseBody(data []byte) (ErrorResponseBody, error)
func (ErrorResponseBody) Encode ¶
func (b ErrorResponseBody) Encode() []byte
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a simple server that handles challenge and verify requests. It uses a cache to store puzzles with a TTL. Clients must solve the puzzle within the TTL. If the puzzle is not solved within the TTL, the server will remove the puzzle from the cache and the client will have to request a new puzzle. In case of correct verification, the server will return a random wisdom.
func (Server) HandleRequest ¶
type VerifiedResponseBody ¶
type VerifiedResponseBody struct {
// contains filtered or unexported fields
}
func DecodeVerifiedResponseBody ¶
func DecodeVerifiedResponseBody(data []byte) (VerifiedResponseBody, error)
func (VerifiedResponseBody) Encode ¶
func (b VerifiedResponseBody) Encode() []byte
type VerifyRequestBody ¶
type VerifyRequestBody struct {
// contains filtered or unexported fields
}
func DecodeVerifyRequestBody ¶
func DecodeVerifyRequestBody(data []byte) (VerifyRequestBody, error)
func (VerifyRequestBody) Encode ¶
func (b VerifyRequestBody) Encode() []byte
Click to show internal directories.
Click to hide internal directories.