namespace NpgsqlRest; /// /// Options for configuring reverse proxy functionality for NpgsqlRest endpoints. /// When an endpoint is marked as a proxy, incoming requests are forwarded to another URL. /// public class ProxyOptions { /// /// Enable proxy functionality for annotated endpoints. /// When false, proxy annotations are ignored. /// public bool Enabled { get; set; } = false; /// /// Base URL (host) for proxy requests (e.g., "https://api.example.com"). /// When set, proxy endpoints will forward requests to this host + the original path. /// Can be overridden per-endpoint via comment annotation. /// public string? Host { get; set; } = null; /// /// Default timeout for all proxy requests. /// public TimeSpan DefaultTimeout { get; set; } = TimeSpan.FromSeconds(30); /// /// When true, original request headers are forwarded to the proxy target. /// Headers in ExcludeHeaders are not forwarded. /// public bool ForwardHeaders { get; set; } = true; /// /// Headers to exclude from forwarding to the proxy target. /// Default excludes Host, Content-Length, and Transfer-Encoding. /// public HashSet ExcludeHeaders { get; set; } = new(StringComparer.OrdinalIgnoreCase) { "Host", "Content-Length", "Transfer-Encoding" }; /// /// When true, forward response headers from proxy back to client. /// Headers in ExcludeResponseHeaders are not forwarded. /// public bool ForwardResponseHeaders { get; set; } = true; /// /// Response headers to exclude from forwarding back to client. /// public HashSet ExcludeResponseHeaders { get; set; } = new(StringComparer.OrdinalIgnoreCase) { "Transfer-Encoding", "Content-Length" }; /// /// Default name for the proxy response status code parameter. /// If a routine has a parameter with this name, it will receive the proxy response status code. /// public string ResponseStatusCodeParameter { get; set; } = "_proxy_status_code"; /// /// Default name for the proxy response body parameter. /// If a routine has a parameter with this name, it will receive the proxy response body. /// public string ResponseBodyParameter { get; set; } = "_proxy_body"; /// /// Default name for the proxy response headers parameter. /// If a routine has a parameter with this name, it will receive the proxy response headers as JSON. /// public string ResponseHeadersParameter { get; set; } = "_proxy_headers"; /// /// Default name for the proxy response content type parameter. /// If a routine has a parameter with this name, it will receive the proxy response content type. /// public string ResponseContentTypeParameter { get; set; } = "_proxy_content_type"; /// /// Default name for the proxy response success parameter. /// If a routine has a parameter with this name, it will receive a boolean indicating if the request succeeded (2xx status). /// public string ResponseSuccessParameter { get; set; } = "_proxy_success"; /// /// Default name for the proxy response error message parameter. /// If a routine has a parameter with this name, it will receive any error message from the proxy request. /// public string ResponseErrorMessageParameter { get; set; } = "_proxy_error_message"; /// /// When true, for upload endpoints marked as proxy, the raw multipart/form-data content /// is forwarded directly to the upstream proxy instead of being processed locally. /// This allows the upstream service to handle file uploads. /// When false (default), upload endpoints with proxy annotation will process uploads locally /// and upload metadata will not be available to the proxy. /// public bool ForwardUploadContent { get; set; } = false; /// /// Base URL for resolving relative paths in proxy annotations (e.g., "proxy /api/test"). /// When set, relative URLs are prefixed with this base URL. When null, the server's /// own listening address is auto-detected at runtime from the first incoming request. /// Example: "http://localhost:5000" /// public string? SelfBaseUrl { get; set; } }