Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions api/host/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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,
Expand Down
28 changes: 22 additions & 6 deletions core/host/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
IntegrationRouteType RouteType = "INTEGRATION"
ExecuteCodeRouteType RouteType = "EXECUTE_CODE"
StaticFilesRouteType RouteType = "STATIC_FILES"
LoadBalancerRouteType RouteType = "LOAD_BALANCER"
)

type Host struct {
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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
}
12 changes: 6 additions & 6 deletions database/host/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading