web

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotLoggedIn     = eris.New("user is not logged in")
	ErrFailedToMarshal = eris.New("failed to marshal the payload")
)

Functions

func DeleteRequest

func DeleteRequest(server string, token string, path string) error

func DoAdminLogin

func DoAdminLogin(cfg *config.Config) (*oauth2.Token, error)

func DoClientLogin added in v0.14.0

func DoClientLogin(cfg *config.Config) (*oauth2.Token, error)

func ExportRsaPrivateKeyAsPem

func ExportRsaPrivateKeyAsPem(key *rsa.PrivateKey) (string, error)

func ExportRsaPublicKeyAsPem

func ExportRsaPublicKeyAsPem(key *rsa.PublicKey) (string, error)

func GenerateRsaKeyPair

func GenerateRsaKeyPair() (*rsa.PrivateKey, *rsa.PublicKey)

func Get added in v0.17.0

func Get[T any](server string, token string, path string) (T, error)

Get is a shortcut for GetRequest but is using generics to make returning a struct easier

func GetRequest

func GetRequest(server string, token string, path string) ([]byte, error)

func GetServer

func GetServer() string

func GetServerFromAlias

func GetServerFromAlias(alias string) string

func GetTokenWithClientCert

func GetTokenWithClientCert(cfg *config.Config) (*oauth2.Token, error)

func GetValidToken

func GetValidToken(cfg *config.Config) (*oauth2.Token, error)

func InitialiseClientKeys

func InitialiseClientKeys() error

func ParseRsaPrivateKeyFromPem

func ParseRsaPrivateKeyFromPem(pemValue []byte) (*rsa.PrivateKey, error)

func ParseRsaPublicKeyFromPem

func ParseRsaPublicKeyFromPem(pemValue []byte) (*rsa.PublicKey, error)

func PatchRequest

func PatchRequest(server string, token string, path string, content []byte) ([]byte, error)

func PostRequest

func PostRequest(server string, token string, path string, content []byte) ([]byte, error)

func PostRequestWithHeaders added in v0.16.0

func PostRequestWithHeaders(server string, token string, path string, content []byte, headers map[string]string, timeout time.Duration) ([]byte, error)

func Put added in v0.17.0

func Put[T any](server string, token string, path string) (T, error)

Put is a shortcut for PutRequest but is using generics to make returning a struct easier

func PutRequest

func PutRequest(server string, token string, path string) ([]byte, error)

func ResolveCredentials

func ResolveCredentials() (*oauth2.Token, error)

func ResolveCredentialsFromAlias

func ResolveCredentialsFromAlias(alias string) (*oauth2.Token, error)

Types

type Client

type Client struct {
	Server string
}

func NewClient

func NewClient(server string) (*Client, error)

func (*Client) Delete

func (c *Client) Delete(endpoint string) error

func (*Client) DeleteRaw

func (c *Client) DeleteRaw(path string) error

func (*Client) Get

func (c *Client) Get(endpoint string, response interface{}, headers ...Header) error

func (*Client) GetRaw

func (c *Client) GetRaw(path string) ([]byte, error)

func (*Client) Post

func (c *Client) Post(endpoint string, request interface{}, response interface{}) error

func (*Client) PostRaw

func (c *Client) PostRaw(path string, content []byte) ([]byte, error)

func (*Client) Put

func (c *Client) Put(endpoint string, request interface{}, response interface{}) error

func (*Client) PutRaw

func (c *Client) PutRaw(path string) ([]byte, error)
type Header struct {
	Header string
	Value  string
}

type IdResponse

type IdResponse struct {
	Id uuid.UUID `json:"id"`
}

IdResponse can be used as a default response object where only an id is returned

type KeyPair

type KeyPair struct {
	PrivateKey *rsa.PrivateKey
	PublicKey  *rsa.PublicKey
	Active     bool
	Expires    uint64
}
var ClientKeyPair *KeyPair

func NewKeyPair

func NewKeyPair(privateKey *rsa.PrivateKey, publicKey *rsa.PublicKey, active bool) *KeyPair

Jump to

Keyboard shortcuts

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