api

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmptyString = ""
)

Variables

This section is empty.

Functions

func CheckValid

func CheckValid(req *http.Request, keeper SecretKeeper) (bool, error)

CheckValid to check if the request is valid from the signing key can't do the judge for you automatically, cause you may want to return something that is defined by yourself, and the call back form is not quite certain.

func Sign

func Sign(content, key string) string

Sign with sha 256

func SignHeader

func SignHeader(s bool)

SignHeader whether to sign http request header or not

Types

type Client

type Client struct {
	Key    string
	Keeper SecretKeeper
}

func DefaultClient

func DefaultClient(key, sec string) *Client

func NewClient

func NewClient(keeper SecretKeeper, key string) *Client

func (*Client) Delete

func (c *Client) Delete(uri, body string, headers ...http.Header) (string, error)

func (*Client) Get

func (c *Client) Get(uri string, headers ...http.Header) (string, error)

func (*Client) Post

func (c *Client) Post(uri, body string, headers ...http.Header) (string, error)

func (*Client) Put

func (c *Client) Put(uri, body string, headers ...http.Header) (string, error)

type DefaultProvider

type DefaultProvider struct {
	AppKey    string
	AppSecret string
}

func (DefaultProvider) GetSecret

func (dp DefaultProvider) GetSecret(key string) (string, error)

type KvPair

type KvPair struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

KvPair is a simple struct for kv pair

type Pairs

type Pairs []KvPair

Pairs is the slice of the KvPair

func (Pairs) Len

func (p Pairs) Len() int

func (Pairs) Less

func (p Pairs) Less(i, j int) bool

func (Pairs) Swap

func (p Pairs) Swap(i, j int)

type SecretKeeper

type SecretKeeper interface {
	GetSecret(key string) (string, error)
}

SecretKeeper the interface to get the secret

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL