idpclient

package
v0.0.0-...-39ac581 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Overview

name 'idpclient' is used although it repeats the name of the outer package 'idp' in order to improve readability functions like e.g. idpclient.New() or idpclient.HttpClient()

Package idpclient provides a client for the IdentityProvider-App

An idpclient with sensible defaults can be created as follows:

c,_ := idpclient.New()

If you don't want to use the defaults provide one or more options:

httpClient := &http.Client{
	Timeout: 2 * time.Second,
}

c, _ := idpclient.New(idpclient.HttpClient(httpClient))

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(options ...Option) (*client, error)

New creates a new Client for the IdentityProvider-App using the following defaults:

  • HttpClient: http.DefaultClient
  • principalCache: An internal implementation is used

If you don't want to use the defaults provide one or more options to this function.

Example (Custom)
package main

import (
	"net/http"
	"time"

	"github.com/d-velop/dvelop-sdk-go/idp/idpclient"
)

func main() {
	// create client with custom http.Client
	httpClient := &http.Client{
		Timeout: 2 * time.Second,
	}
	_, _ = idpclient.New(idpclient.HttpClient(httpClient))
}
Output:

Example (Default)
package main

import (
	"github.com/d-velop/dvelop-sdk-go/idp/idpclient"
)

func main() {
	// create client with defaults
	_, _ = idpclient.New()
}
Output:

Types

type Cache

type Cache interface {
	// Get an item from the cache. Returns the item or nil, and a bool indicating
	// whether the key was found.
	Get(key string) (item interface{}, found bool)

	// Add an item to the cache, replacing any existing item.
	// If cacheDuration is <= 0 the item never expires
	Set(key string, item interface{}, cacheDuration time.Duration)
}

Cache is an interface representing the ability to cache arbitrary items for a certain amount of time

type Option

type Option func(*client) error

func HttpClient

func HttpClient(h *http.Client) Option

HttpClient explicitly sets the http.Client which should be used to make request against the IdentityProvider-App

func PrincipalCache

func PrincipalCache(pc Cache) Option

Jump to

Keyboard shortcuts

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