nitric

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

Functions

func NewKv added in v1.0.0

func NewKv(name string) *kvstore

func NewQueue

func NewQueue(name string) *queue

func NewSecret

func NewSecret(name string) *secret

func Run

func Run() error

Run will run the function and callback the required handlers when these events are received.

Types

type Api

type Api interface {
	Get(path string, handler handler.HttpMiddleware, opts ...MethodOption)
	Put(path string, handler handler.HttpMiddleware, opts ...MethodOption)
	Patch(path string, handler handler.HttpMiddleware, opts ...MethodOption)
	Post(path string, handler handler.HttpMiddleware, opts ...MethodOption)
	Delete(path string, handler handler.HttpMiddleware, opts ...MethodOption)
	Options(path string, handler handler.HttpMiddleware, opts ...MethodOption)
	NewRoute(path string, middleware ...handler.HttpMiddleware) Route
}

Api Resource represents an HTTP API, capable of routing and securing incoming HTTP requests to handlers. path is the route path matcher e.g. '/home'. Supports path params via colon prefix e.g. '/customers/:customerId' handler the handler to register for callbacks.

Note: to chain middleware use handler.ComposeHttpMiddlware()

func NewApi

func NewApi(name string, opts ...ApiOption) (Api, error)

NewApi Registers a new API Resource.

The returned API object can be used to register Routes and Methods, with Handlers.

type ApiDetails

type ApiDetails struct {
	Details
	URL string
}

type ApiOption

type ApiOption = func(api *api)

func WithMiddleware

func WithMiddleware(middleware ...handler.HttpMiddleware) ApiOption

func WithPath

func WithPath(path string) ApiOption

WithPath - Prefixes API with the given path

func WithSecurity

func WithSecurity(oidcOptions OidcOptions) ApiOption

func WithSecurityJwtRule

func WithSecurityJwtRule(name string, rule JwtSecurityRule) ApiOption

type Bucket

func NewBucket

func NewBucket(name string) Bucket

NewBucket register this bucket as a required resource for the calling function/container and register the permissions required by the currently scoped function for this resource.

type BucketPermission

type BucketPermission string
const (
	BucketRead   BucketPermission = "read"
	BucketWrite  BucketPermission = "write"
	BucketDelete BucketPermission = "delete"
)

type Details

type Details struct {
	// The identifier of the resource
	ID string
	// The provider this resource is deployed with (e.g. aws)
	Provider string
	// The service this resource is deployed on (e.g. ApiGateway)
	Service string
}

type JwtSecurityRule

type JwtSecurityRule struct {
	Issuer    string
	Audiences []string
}

type KvStore added in v1.0.0

type KvStore interface {
	Allow(KvStorePermission, ...KvStorePermission) (keyvalue.Store, error)
}

type KvStorePermission added in v1.0.0

type KvStorePermission string
const (
	KvStoreWrite  KvStorePermission = "write"
	KvStoreRead   KvStorePermission = "read"
	KvStoreDelete KvStorePermission = "delete"
)

type Manager

type Manager interface {
	Run() error
	// contains filtered or unexported methods
}

Manager is the top level object that resources are created on.

func New

func New() Manager

New is used to create the top level resource manager. Note: this is not required if you are using resources.NewApi() and the like. These use a default manager instance.

type MethodOption

type MethodOption = func(mo *methodOptions)

func WithMethodSecurity

func WithMethodSecurity(oidcOptions OidcOptions) MethodOption

func WithNoMethodSecurity

func WithNoMethodSecurity() MethodOption

type OidcOptions added in v1.0.0

type OidcOptions struct {
	Name      string
	Issuer    string
	Audiences []string
	Scopes    []string
}

type OidcSecurityDefinition added in v1.0.0

type OidcSecurityDefinition interface{}

func NewOidcSecurityDefinition added in v1.0.0

func NewOidcSecurityDefinition(apiName string, options OidcOptions) (OidcSecurityDefinition, error)

type Queue

type Queue interface {
	Allow(QueuePermission, ...QueuePermission) (queues.Queue, error)
}

type QueuePermission

type QueuePermission string
const (
	QueueEnqueue QueuePermission = "enqueue"
	QueueDequeue QueuePermission = "dequeue"
)

type Route

type Route interface {
	All(handler handler.HttpMiddleware, opts ...MethodOption)
	Get(handler handler.HttpMiddleware, opts ...MethodOption)
	Patch(handler handler.HttpMiddleware, opts ...MethodOption)
	Put(handler handler.HttpMiddleware, opts ...MethodOption)
	Post(handler handler.HttpMiddleware, opts ...MethodOption)
	Delete(handler handler.HttpMiddleware, opts ...MethodOption)
	Options(handler handler.HttpMiddleware, opts ...MethodOption)
	ApiName() string
}

Route providers convenience functions to register a handler in a single method.

type Schedule

type Schedule interface {
	Cron(cron string, middleware ...handler.IntervalMiddleware)
	Every(rate string, middleware ...handler.IntervalMiddleware)
}

func NewSchedule

func NewSchedule(name string) Schedule

NewSchedule provides a new schedule, which can be configured with a rate/cron and a callback to run on the schedule.

type Secret

type Secret interface{}

type SecretPermission

type SecretPermission string
const (
	SecretAccess SecretPermission = "access"
	SecretPut    SecretPermission = "put"
)

type SecurityOption added in v1.0.0

type SecurityOption = func(scopes []string) OidcOptions

func OidcRule added in v1.0.0

func OidcRule(name string, issuer string, audiences []string) SecurityOption

type SubscribableTopic

type SubscribableTopic interface {
	Allow(TopicPermission, ...TopicPermission) (Topic, error)

	// Subscribe will register and start a subscription handler that will be called for all events from this topic.
	Subscribe(...handler.MessageMiddleware)
}

func NewTopic

func NewTopic(name string) SubscribableTopic

NewTopic creates a new Topic with the give permissions.

type Topic

type Topic interface {
	topics.Topic
}

type TopicPermission

type TopicPermission string

TopicPermission defines the available permissions on a topic

const (
	// TopicPublishing is required to call Publish on a topic.
	TopicPublish TopicPermission = "publish"
)

type Websocket

type Websocket interface {
	Name() string
	On(eventType handler.WebsocketEventType, mwares ...handler.WebsocketMiddleware)
	Send(ctx context.Context, connectionId string, message []byte) error
	Close(ctx context.Context, connectionId string) error
}

func NewWebsocket

func NewWebsocket(name string) (Websocket, error)

NewCollection register this collection as a required resource for the calling function/container.

Jump to

Keyboard shortcuts

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