Documentation
¶
Index ¶
- func BuildAPIUpstreamForCreate(backendID uint, input CreateInput) (models.APIUpstream, error)
- func EncryptAPIUpstreamCredential(cipher *byokcrypto.Cipher, upstreamID uint, ...) (string, error)
- type APIUpstreamCredential
- type APIUpstreamManagementResponse
- type CreateInput
- type CreateRequest
- type Creator
- type Handler
- func (h *Handler) Create(c *app.Context, req CreateRequest) (api.Created[APIUpstreamManagementResponse], error)
- func (h *Handler) Delete(c *app.Context, req IDRequest) (api.StatusResponse, error)
- func (h *Handler) Get(c *app.Context, req IDRequest) (APIUpstreamManagementResponse, error)
- func (h *Handler) List(c *app.Context, req ListRequest) (api.PaginatedResponse[APIUpstreamManagementResponse], error)
- func (h *Handler) Update(c *app.Context, req UpdateRequest) (api.StatusResponse, error)
- type IDRequest
- type ListRequest
- type UpdateRequest
- type UpstreamPublisher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAPIUpstreamForCreate ¶
func BuildAPIUpstreamForCreate(backendID uint, input CreateInput) (models.APIUpstream, error)
BuildAPIUpstreamForCreate normalizes and validates a create input into the database model that Creator may persist. It performs no encryption or I/O.
func EncryptAPIUpstreamCredential ¶
func EncryptAPIUpstreamCredential(cipher *byokcrypto.Cipher, upstreamID uint, authType models.APIUpstreamAuthType, credential APIUpstreamCredential) (string, error)
EncryptAPIUpstreamCredential validates the credential's auth shape and encrypts its JSON representation with the persisted upstream ID as AEAD AAD.
Types ¶
type APIUpstreamCredential ¶
type APIUpstreamCredential = protocol.APIUpstreamCredential
APIUpstreamCredential is the plaintext-only credential input used at the administrative boundary. It is never embedded in a management response.
func DecryptAPIUpstreamCredential ¶
func DecryptAPIUpstreamCredential(cipher *byokcrypto.Cipher, upstreamID uint, authType models.APIUpstreamAuthType, ciphertext string) (APIUpstreamCredential, error)
DecryptAPIUpstreamCredential opens a base64-encoded credential and validates its full shape again, so ciphertext cannot be reused for another auth type.
type APIUpstreamManagementResponse ¶
type APIUpstreamManagementResponse struct {
ID uint `json:"id"`
BackendID uint `json:"backend_id"`
Name string `json:"name"`
BaseURL string `json:"base_url"`
Weight int `json:"weight"`
Priority int `json:"priority"`
AuthType models.APIUpstreamAuthType `json:"auth_type"`
Status int `json:"status"`
CredentialConfigured bool `json:"credential_configured"`
ProxyURLConfigured bool `json:"proxy_url_configured"`
HeaderOverride map[string]string `json:"header_override,omitempty"`
}
APIUpstreamManagementResponse is the credential-safe response shape for administration APIs. Encrypted secret fields never exist on this type, and header overrides are included only after the handler verifies manage access.
func NewAPIUpstreamManagementResponse ¶
func NewAPIUpstreamManagementResponse(upstream models.APIUpstream, includeHeaderOverride ...bool) APIUpstreamManagementResponse
type CreateInput ¶
type CreateInput struct {
Name string `json:"name" binding:"required,max=64"`
BaseURL string `json:"base_url" binding:"required"`
Weight int `json:"weight"`
Priority int `json:"priority"`
AuthType models.APIUpstreamAuthType `json:"auth_type"`
Credential *APIUpstreamCredential `json:"credential"`
ProxyURL *string `json:"proxy_url"`
HeaderOverride map[string]string `json:"header_override"`
Status *int `json:"status"`
}
type CreateRequest ¶
type CreateRequest struct {
BackendID uint `json:"backend_id" binding:"required"`
CreateInput
}
type Creator ¶
type Creator struct {
Cipher *byokcrypto.Cipher
}
func (Creator) CreateInTx ¶
func (c Creator) CreateInTx(ctx dao.Context, backendID uint, input CreateInput) (models.APIUpstream, error)
type Handler ¶
type Handler struct {
App app.Application
Publisher UpstreamPublisher
Creator Creator
}
func (*Handler) Create ¶
func (h *Handler) Create(c *app.Context, req CreateRequest) (api.Created[APIUpstreamManagementResponse], error)
func (*Handler) List ¶
func (h *Handler) List(c *app.Context, req ListRequest) (api.PaginatedResponse[APIUpstreamManagementResponse], error)
func (*Handler) Update ¶
func (h *Handler) Update(c *app.Context, req UpdateRequest) (api.StatusResponse, error)
type ListRequest ¶
type UpdateRequest ¶
type UpdateRequest struct {
ID string `uri:"id" binding:"required"`
Fields map[string]any `json:"-"`
}
func (*UpdateRequest) SetBodyMap ¶
func (r *UpdateRequest) SetBodyMap(v map[string]any)