Documentation
¶
Index ¶
- Constants
- func BuildExport(snapshot DocumentSnapshot, server string) ([]byte, error)
- func GatewayServer(c *app.Context, slug string) string
- func LimitRequestBody(next gin.HandlerFunc) gin.HandlerFunc
- type DocumentResponse
- type DocumentSnapshot
- type Handler
- func (h *Handler) Get(c *app.Context, req IDRequest) (DocumentResponse, error)
- func (h *Handler) Import(c *app.Context, req ImportCommand) (api.Created[ImportResult], error)
- func (h *Handler) Preview(c *app.Context, req PreviewRequest) (PreviewResponse, error)
- func (h *Handler) Update(c *app.Context, req UpdateRequest) (DocumentResponse, error)
- type IDRequest
- type ImportCommand
- type ImportPublisher
- type ImportResult
- type Importer
- type OpenAPIDocumentFinder
- func (OpenAPIDocumentFinder) Find(ctx dao.Context, serviceID uint) (DocumentSnapshot, error)
- func (OpenAPIDocumentFinder) FindVisible(ctx dao.Context, serviceID uint, routeIDs *[]uint) (DocumentSnapshot, error)
- func (OpenAPIDocumentFinder) FindVisibleInTx(tx dao.Context, serviceID uint, routeIDs *[]uint) (DocumentSnapshot, error)
- type PreviewRequest
- type PreviewResponse
- type Problem
- type RouteDocument
- type RouteDocumentUpdate
- type RouteDraft
- type ServerDraft
- type ServiceDocument
- type ServiceDocumentUpdate
- type ServiceDraft
- type UpdateRequest
- type UpstreamDraft
Constants ¶
const MaxRequestBodyBytes = coreopenapi.MaxDocumentBytes + 1024
Variables ¶
This section is empty.
Functions ¶
func BuildExport ¶
func BuildExport(snapshot DocumentSnapshot, server string) ([]byte, error)
BuildExport produces the standard public OpenAPI representation for a document snapshot without exposing management-only route fields.
func GatewayServer ¶
GatewayServer returns the public gateway URL used by exported documents.
func LimitRequestBody ¶
func LimitRequestBody(next gin.HandlerFunc) gin.HandlerFunc
LimitRequestBody bounds the OpenAPI envelope before strict JSON binding.
Types ¶
type DocumentResponse ¶
type DocumentResponse struct {
DocumentSnapshot
Export json.RawMessage `json:"export"`
}
type DocumentSnapshot ¶
type DocumentSnapshot struct {
Service ServiceDocument `json:"service"`
Routes []RouteDocument `json:"routes"`
}
type Handler ¶
type Handler struct {
App app.Application
Importer Importer
Finder OpenAPIDocumentFinder
}
func (*Handler) Import ¶
func (h *Handler) Import(c *app.Context, req ImportCommand) (api.Created[ImportResult], error)
func (*Handler) Preview ¶
func (h *Handler) Preview(c *app.Context, req PreviewRequest) (PreviewResponse, error)
func (*Handler) Update ¶
func (h *Handler) Update(c *app.Context, req UpdateRequest) (DocumentResponse, error)
type ImportCommand ¶
type ImportCommand struct {
Document json.RawMessage `json:"document" binding:"required"`
Slug string `json:"slug" binding:"required,max=64"`
Choices []coreopenapi.RouteGroupChoice `json:"choices"`
SelectedServer *int `json:"selected_server"`
BackendName string `json:"backend_name" binding:"required,max=64"`
Upstream UpstreamDraft `json:"upstream" binding:"required"`
PricePerCall int64 `json:"price_per_call"`
}
type ImportPublisher ¶
type ImportResult ¶
type Importer ¶
type Importer struct {
UpstreamCreator api_upstream.Creator
Publisher ImportPublisher
}
func (Importer) Import ¶
func (i Importer) Import(ctx dao.Context, cmd ImportCommand) (ImportResult, error)
type OpenAPIDocumentFinder ¶
type OpenAPIDocumentFinder struct{}
func (OpenAPIDocumentFinder) Find ¶
func (OpenAPIDocumentFinder) Find(ctx dao.Context, serviceID uint) (DocumentSnapshot, error)
func (OpenAPIDocumentFinder) FindVisible ¶
func (OpenAPIDocumentFinder) FindVisible(ctx dao.Context, serviceID uint, routeIDs *[]uint) (DocumentSnapshot, error)
FindVisible returns a service document containing only enabled routes in the supplied authorization scope. A nil route scope retains every enabled route.
func (OpenAPIDocumentFinder) FindVisibleInTx ¶
func (OpenAPIDocumentFinder) FindVisibleInTx(tx dao.Context, serviceID uint, routeIDs *[]uint) (DocumentSnapshot, error)
FindVisibleInTx composes the scoped document read into a caller-owned core read transaction so authorization and documents can share one snapshot.
type PreviewRequest ¶
type PreviewRequest struct {
Document json.RawMessage `json:"document" binding:"required"`
}
type PreviewResponse ¶
type PreviewResponse struct {
Service ServiceDraft `json:"service"`
Servers []ServerDraft `json:"servers"`
Routes []RouteDraft `json:"routes"`
Problems []Problem `json:"problems"`
}
type Problem ¶
type Problem = coreopenapi.Problem
type RouteDocument ¶
type RouteDocumentUpdate ¶
type RouteDocumentUpdate struct {
ID uint `json:"id" binding:"required"`
UpdatedAt int64 `json:"updated_at" binding:"required"`
Paths map[string]models.OpenAPIPathItem `json:"paths" binding:"required"`
}
type RouteDraft ¶
type RouteDraft struct {
Slug string `json:"slug"`
DisplayName string `json:"display_name"`
UpstreamPath string `json:"upstream_path"`
AllowedMethods []string `json:"allowed_methods"`
Paths []string `json:"paths"`
PublicPaths map[string]string `json:"public_paths"`
PathCount int `json:"path_count"`
OperationCount int `json:"operation_count"`
}
type ServerDraft ¶
type ServiceDocument ¶
type ServiceDocumentUpdate ¶
type ServiceDocumentUpdate struct {
ID uint `json:"id" binding:"required"`
UpdatedAt int64 `json:"updated_at" binding:"required"`
Document models.OpenAPIServiceDocument `json:"document" binding:"required"`
}
type ServiceDraft ¶
type UpdateRequest ¶
type UpdateRequest struct {
ID uint `uri:"id" json:"-" binding:"required"`
Service ServiceDocumentUpdate `json:"service" binding:"required"`
Routes []RouteDocumentUpdate `json:"routes" binding:"required"`
}
type UpstreamDraft ¶
type UpstreamDraft struct {
Name string `json:"name" binding:"required,max=64"`
BaseURL string `json:"base_url"`
Weight int `json:"weight"`
Priority int `json:"priority"`
AuthType models.APIUpstreamAuthType `json:"auth_type"`
Credential *api_upstream.APIUpstreamCredential `json:"credential"`
ProxyURL *string `json:"proxy_url"`
HeaderOverride map[string]string `json:"header_override"`
Status *int `json:"status"`
}
UpstreamDraft carries the non-document fields needed to create the first upstream. BaseURL is optional because a selected OpenAPI server supplies it; documents without servers require it in selectedUpstreamInput.