api_route

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateRequest

type CreateRequest struct {
	APIServiceID          uint                     `json:"api_service_id" binding:"required"`
	Slug                  string                   `json:"slug" binding:"max=64"`
	Protocols             []models.APIProtocol     `json:"protocols"`
	AllowedMethods        []string                 `json:"allowed_methods"`
	WebSocketSubprotocols []string                 `json:"websocket_subprotocols"`
	UpstreamPath          string                   `json:"upstream_path"`
	ForwardSubpath        bool                     `json:"forward_subpath"`
	ExampleRequest        models.APIRequestExample `json:"example_request"`
	Target                RouteTargetCommand       `json:"target" binding:"required"`
	Status                *int                     `json:"status"`
}

type Handler

type Handler struct {
	App             app.Application
	Publisher       RoutePublisher
	UpstreamCreator api_upstream.Creator
}

func (*Handler) Create

func (h *Handler) Create(c *app.Context, req CreateRequest) (api.Created[models.APIRoute], error)

func (*Handler) Delete

func (h *Handler) Delete(c *app.Context, req IDRequest) (api.StatusResponse, error)

func (*Handler) Get

func (h *Handler) Get(c *app.Context, req IDRequest) (models.APIRoute, error)

func (*Handler) List

func (*Handler) Preview

Preview returns every statically configured candidate for a route draft. It is deliberately read-only: it neither selects a candidate nor calls any runtime gate, transport, accounting, observation, or publish component.

func (*Handler) Update

func (h *Handler) Update(c *app.Context, req UpdateRequest) (api.StatusResponse, error)

type IDRequest

type IDRequest struct {
	ID string `uri:"id" binding:"required"`
}

type ListRequest

type ListRequest struct {
	api.PaginationQuery
	APIServiceID *uint  `form:"api_service_id"`
	Search       string `form:"search"`
	Status       *int   `form:"status"`
}

type PreviewEndpoint

type PreviewEndpoint struct {
	UpstreamID   uint   `json:"upstream_id"`
	UpstreamName string `json:"upstream_name"`
	Status       int    `json:"status"`
	Priority     int    `json:"priority"`
	Weight       int    `json:"weight"`
	FinalURL     string `json:"final_url"`
}

type PreviewRequest

type PreviewRequest struct {
	APIServiceID   uint                     `json:"api_service_id" binding:"required"`
	Slug           string                   `json:"slug" binding:"max=64"`
	UpstreamPath   string                   `json:"upstream_path"`
	ForwardSubpath bool                     `json:"forward_subpath"`
	Sample         models.APIRequestExample `json:"sample"`
	Target         RouteTargetCommand       `json:"target"`
}

type RoutePreviewResponse

type RoutePreviewResponse struct {
	Endpoints   []PreviewEndpoint `json:"endpoints"`
	Diagnostics []string          `json:"diagnostics"`
}

type RoutePublisher

type RoutePublisher interface {
	PublishRoute(context.Context, string, models.APIRoute) error
	PublishUpstream(context.Context, string, models.APIUpstream) error
}

type RouteTargetCommand

type RouteTargetCommand struct {
	Mode          string                    `json:"mode" binding:"required,oneof=existing create"`
	BackendID     uint                      `json:"backend_id"`
	Backend       *api_backend.CreateInput  `json:"backend"`
	FirstUpstream *api_upstream.CreateInput `json:"first_upstream"`
}

RouteTargetCommand selects an existing backend or atomically creates a new backend with its first upstream before attaching the route to it.

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)

Jump to

Keyboard shortcuts

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