client

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConsulSkipTLSVerify = "CONSUL_SKIP_VERIFY"
	ConsulEnterprise    = "CONSUL_ENTERPRISE"
)

Variables

This section is empty.

Functions

func ConsulContextMiddleware

func ConsulContextMiddleware(logger *log.Logger) func(http.Handler) http.Handler

ConsulContextMiddleware is a middleware that extracts Consul connection details from the request headers and adds them to the request context. This allows the application to have a single, unified way of accessing Consul connection details regardless of the transport.

func DeleteConsulHttpClientForSession

func DeleteConsulHttpClientForSession(sessionId string)

DeleteHttpClient removes the HTTP client for the given session

func EndSessionHandler

func EndSessionHandler(_ context.Context, session server.ClientSession, logger *log.Logger)

EndSessionHandler cleans up clients when the session ends

func NewHttpClientFromContext

func NewHttpClientFromContext(ctx context.Context, logger *log.Logger) *http.Client

NewHttpClient creates a http.Client with optional TLS verification skip

func NewSecurityHandler

func NewSecurityHandler(handler http.Handler, allowedOrigins []string, corsMode string, logger *log.Logger) http.Handler

NewSecurityHandler creates a new security handler

func NewSessionHandler

func NewSessionHandler(ctx context.Context, session server.ClientSession, logger *log.Logger)

NewSessionHandler initializes clients for the session

Types

type CORSConfig

type CORSConfig struct {
	AllowedOrigins []string
	Mode           string // "strict", "development", "disabled"
}

CORSConfig holds CORS configuration

func LoadCORSConfigFromEnv

func LoadCORSConfigFromEnv() CORSConfig

LoadCORSConfigFromEnv loads CORS configuration from environment variables

type ConsulHttpClient

type ConsulHttpClient struct {
	SessionID string
	Address   string
	Token     string

	Logger *log.Logger
	// contains filtered or unexported fields
}

func GetConsulHttpClient

func GetConsulHttpClient(sessionId string) *ConsulHttpClient

GetConsulHttpClient retrieves the Consul client for the given session

func GetGetConsulHttpClientFromContext

func GetGetConsulHttpClientFromContext(ctx context.Context, logger *log.Logger) (*ConsulHttpClient, error)

GetHttpClientFromContext extracts HTTP client from the MCP context

func NewConsulClient

func NewConsulClient(ctx context.Context, sessionId string, logger *log.Logger) *ConsulHttpClient

NewConsulClient creates a new Consul client for the given session

func NewConsulClientFromContext

func NewConsulClientFromContext(ctx context.Context, logger *log.Logger) (*ConsulHttpClient, error)

NewConsulClientFromContext creates a new Consul client from the given context

func (*ConsulHttpClient) Get

func (c *ConsulHttpClient) Get(path string, queryParams url.Values, callOptions ...string) ([]byte, error)

func (*ConsulHttpClient) Post

func (c *ConsulHttpClient) Post(path string, queryParams url.Values, data interface{}, callOptions ...string) ([]byte, error)

func (*ConsulHttpClient) Put

func (c *ConsulHttpClient) Put(path string, queryParams url.Values, data interface{}, callOptions ...string) ([]byte, error)

type Service

type Service map[string]interface{}

type Services

type Services map[string]interface{}

Services represents a map of service names to their tags

Jump to

Keyboard shortcuts

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