diff --git a/api/host/converter.go b/api/host/converter.go index 1a2ecd98..fd64ca96 100644 --- a/api/host/converter.go +++ b/api/host/converter.go @@ -153,7 +153,7 @@ func toRouteSettingsDto(settings *host.RouteSettings) *routeSettingsDto { } } -func toStaticResponseDto(response *host.RouteStaticResponse) *staticResponseDto { +func toStaticResponseDto(response *host.StaticResponse) *staticResponseDto { if response == nil { return nil } @@ -165,7 +165,7 @@ func toStaticResponseDto(response *host.RouteStaticResponse) *staticResponseDto } } -func toIntegrationConfigDto(config *host.RouteIntegrationConfig) *integrationConfigDto { +func toIntegrationConfigDto(config *host.Integration) *integrationConfigDto { if config == nil { return nil } @@ -176,7 +176,7 @@ func toIntegrationConfigDto(config *host.RouteIntegrationConfig) *integrationCon } } -func toRouteSourceCodeDto(sourceCode *host.RouteSourceCode) *routeSourceCodeDto { +func toRouteSourceCodeDto(sourceCode *host.SourceCode) *routeSourceCodeDto { if sourceCode == nil { return nil } @@ -268,35 +268,35 @@ func toRouteSettings(input *routeSettingsDto) *host.RouteSettings { } } -func toRouteStaticResponse(input *staticResponseDto) *host.RouteStaticResponse { +func toRouteStaticResponse(input *staticResponseDto) *host.StaticResponse { if input == nil { return nil } - return &host.RouteStaticResponse{ + return &host.StaticResponse{ StatusCode: getIntValue(input.StatusCode), Payload: input.Payload, Headers: getMapValue(input.Headers), } } -func toRouteIntegrationConfig(input *integrationConfigDto) *host.RouteIntegrationConfig { +func toRouteIntegrationConfig(input *integrationConfigDto) *host.Integration { if input == nil { return nil } - return &host.RouteIntegrationConfig{ + return &host.Integration{ IntegrationID: getUuidValue(input.IntegrationId), OptionID: getStringValue(input.OptionId), } } -func toRouteSourceCode(input *routeSourceCodeDto) *host.RouteSourceCode { +func toRouteSourceCode(input *routeSourceCodeDto) *host.SourceCode { if input == nil { return nil } - return &host.RouteSourceCode{ + return &host.SourceCode{ Language: *input.Language, Contents: getStringValue(input.Code), MainFunction: input.MainFunction, diff --git a/core/host/model.go b/core/host/model.go index cbd65bfd..756d719a 100644 --- a/core/host/model.go +++ b/core/host/model.go @@ -27,6 +27,7 @@ const ( IntegrationRouteType RouteType = "INTEGRATION" ExecuteCodeRouteType RouteType = "EXECUTE_CODE" StaticFilesRouteType RouteType = "STATIC_FILES" + LoadBalancerRouteType RouteType = "LOAD_BALANCER" ) type Host struct { @@ -58,12 +59,12 @@ type Route struct { RedirectCode *int AccessListID *uuid.UUID Settings RouteSettings - Response *RouteStaticResponse - Integration *RouteIntegrationConfig - SourceCode *RouteSourceCode + Response *StaticResponse + Integration *Integration + SourceCode *SourceCode } -type RouteSourceCode struct { +type SourceCode struct { Language CodeLanguage Contents string MainFunction *string @@ -77,13 +78,13 @@ type RouteSettings struct { Custom *string } -type RouteStaticResponse struct { +type StaticResponse struct { StatusCode int Headers map[string]string Payload *string } -type RouteIntegrationConfig struct { +type Integration struct { IntegrationID uuid.UUID OptionID string } @@ -101,3 +102,18 @@ type VPN struct { Name string Host *string } + +type LoadBalancer struct { + Backends []LoadBalancerBackend +} + +type LoadBalancerBackend struct { + Weight *int + Address string + CircuitBreaker *CircuitBreaker +} + +type CircuitBreaker struct { + MaxFailures int + OpenSeconds int +} diff --git a/database/host/converter.go b/database/host/converter.go index ea292e47..1a860eb8 100644 --- a/database/host/converter.go +++ b/database/host/converter.go @@ -37,26 +37,26 @@ func toDomain(model *hostModel) (*host.Host, error) { return nil, err } - var response *host.RouteStaticResponse + var response *host.StaticResponse if route.StaticResponseCode != nil { - response = &host.RouteStaticResponse{ + response = &host.StaticResponse{ StatusCode: *route.StaticResponseCode, Headers: headers, Payload: route.StaticResponsePayload, } } - var integration *host.RouteIntegrationConfig + var integration *host.Integration if route.IntegrationOptionID != nil { - integration = &host.RouteIntegrationConfig{ + integration = &host.Integration{ IntegrationID: *route.IntegrationID, OptionID: *route.IntegrationOptionID, } } - var sourceCode *host.RouteSourceCode + var sourceCode *host.SourceCode if route.CodeLanguage != nil { - sourceCode = &host.RouteSourceCode{ + sourceCode = &host.SourceCode{ Language: host.CodeLanguage(*route.CodeLanguage), Contents: *route.CodeContents, MainFunction: route.CodeMainFunction,