sdk

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidHTTPMethod = errors.New("not a valid HTTPMethod")
View Source
var ErrInvalidRateLimitDescriptionBy = errors.New("not a valid RateLimitDescriptionBy")

Functions

This section is empty.

Types

type HTTPMethod

type HTTPMethod uint8

HTTPMethod ... ENUM(unspecified, get, put, post, delete, patch)

const (
	// HTTPMethodUnspecified is a HTTPMethod of type Unspecified.
	HTTPMethodUnspecified HTTPMethod = iota
	// HTTPMethodGet is a HTTPMethod of type Get.
	HTTPMethodGet
	// HTTPMethodPut is a HTTPMethod of type Put.
	HTTPMethodPut
	// HTTPMethodPost is a HTTPMethod of type Post.
	HTTPMethodPost
	// HTTPMethodDelete is a HTTPMethod of type Delete.
	HTTPMethodDelete
	// HTTPMethodPatch is a HTTPMethod of type Patch.
	HTTPMethodPatch
)

func ParseHTTPMethod

func ParseHTTPMethod(name string) (HTTPMethod, error)

ParseHTTPMethod attempts to convert a string to a HTTPMethod.

func (HTTPMethod) IsValid

func (x HTTPMethod) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (HTTPMethod) String

func (x HTTPMethod) String() string

String implements the Stringer interface.

type Handler

type Handler struct {
	Method string
	HandlerSettings
	AllowedHTTPMethods []HTTPMethod
	ProcessFunc        HandlerFunc
}

Handler ...

type HandlerFunc

type HandlerFunc func(ctx context.Context, req *ProcessRequest) (*ProcessResponse, error)

HandlerFunc ...

type HandlerSettings

type HandlerSettings struct {
	AuditEnabled           bool
	RateLimiterDescription *RateLimiterDescription
	RequiredAuthentication bool
	RequiredPermissions    []string
}

HandlerSettings ...

type NewOptions

type NewOptions struct {
	ServerAddress         string
	Auth0Domain           string
	Auth0Audience         string
	M2MValidation         bool
	GlobalHandlerSettings HandlerSettings
	Handlers              []Handler
	ServerCloseTimeout    time.Duration
	Logger                *slog.Logger
}

NewOptions ...

type ProcessRequest

type ProcessRequest struct {
	HTTPMethod         HTTPMethod
	Path               string
	Query              url.Values
	Body               []byte
	Headers            http.Header
	SubjectInformation *SubjectInformation
}

ProcessRequest ...

type ProcessResponse

type ProcessResponse struct {
	Body       []byte
	StatusCode int
	Headers    http.Header
}

ProcessResponse ...

type RateLimitDescriptionBy

type RateLimitDescriptionBy uint8

RateLimitDescriptionBy ... ENUM(ip, subject_id)

const (
	// RateLimitDescriptionByIp is a RateLimitDescriptionBy of type Ip.
	RateLimitDescriptionByIp RateLimitDescriptionBy = iota
	// RateLimitDescriptionBySubjectId is a RateLimitDescriptionBy of type Subject_id.
	RateLimitDescriptionBySubjectId
)

func ParseRateLimitDescriptionBy

func ParseRateLimitDescriptionBy(name string) (RateLimitDescriptionBy, error)

ParseRateLimitDescriptionBy attempts to convert a string to a RateLimitDescriptionBy.

func (RateLimitDescriptionBy) IsValid

func (x RateLimitDescriptionBy) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (RateLimitDescriptionBy) String

func (x RateLimitDescriptionBy) String() string

String implements the Stringer interface.

type RateLimiterDescription

type RateLimiterDescription struct {
	By     RateLimitDescriptionBy
	Rate   uint64
	Burst  uint64
	Period time.Duration
}

RateLimiterDescription ...

type SDK

type SDK struct {
	// contains filtered or unexported fields
}

SDK that helps integrate with api-gateway.

func New

func New(opts NewOptions) (*SDK, error)

New returns new SDK with provided options.

func (*SDK) RegisterHandler

func (s *SDK) RegisterHandler(h Handler) error

RegisterHandler in SDK. All registrations must be done before Run.

func (*SDK) Run

func (s *SDK) Run(ctx context.Context) error

Run gRPC server.

type SubjectInformation

type SubjectInformation struct {
	ID          string
	Permissions []string
}

SubjectInformation ...

Jump to

Keyboard shortcuts

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