api

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Executor runtime.Executor
}

API is the main entry point for the Sentra API. It is used to execute policies and rules.

func NewAPI

func NewAPI(executor runtime.Executor) *API

NewAPI creates a new API instance.

type DecisionRequest

type DecisionRequest struct {
	Facts map[string]any `json:"facts"`
}

DecisionRequest represents the request body for rule execution

type DecisionResponse

type DecisionResponse struct {
	Decisions []*runtime.ExecutorOutput `json:"decisions"`
	Error     string                    `json:"error,omitempty"`
}

DecisionResponse represents the response from rule execution

type HTTPAPI

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

HTTPAPI provides HTTP endpoints for rule execution

func NewHTTPAPI

func NewHTTPAPI(executor runtime.Executor) *HTTPAPI

NewHTTPAPI creates a new HTTP API instance

func (*HTTPAPI) Setup

func (api *HTTPAPI) Setup(ctx context.Context, port int, listen []string) error

func (*HTTPAPI) StartServer

func (api *HTTPAPI) StartServer(ctx context.Context, port int, listen []string)

StartServer starts the HTTP server on the specified addresses

func (*HTTPAPI) StopServer

func (api *HTTPAPI) StopServer(ctx context.Context) error

StopServer gracefully stops the HTTP server

type ListenerServerPair

type ListenerServerPair struct {
	Listener net.Listener
	Server   *http.Server
}

func NewListenerServerPair

func NewListenerServerPair(listener net.Listener, server *http.Server) *ListenerServerPair

func (*ListenerServerPair) Close

func (p *ListenerServerPair) Close() error

type ProblemDetails

type ProblemDetails struct {
	Type     string         `json:"type,omitempty"`
	Title    string         `json:"title"`
	Status   int            `json:"status,omitempty"`
	Detail   string         `json:"detail,omitempty"`
	Instance string         `json:"instance,omitempty"`
	Ext      map[string]any `json:"-"`
}

ProblemDetails represents an RFC 9457 Problem Details for HTTP APIs

func NewProblemDetails

func NewProblemDetails(type_, title, detail, instance string, status int, ext map[string]any) *ProblemDetails

func (*ProblemDetails) MarshalJSON

func (p *ProblemDetails) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshaling for ProblemDetails

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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