fn build(self, params: &KongBuildParams) -> Result<Kong> {
        let KongBuildParams {
            region,
            service,
            name,
            kong,
        } = params;
        debug!("Building Kong API {} for {}", &name, &service);

        let hosts = self.build_hosts(&kong.base_url)?;
        if hosts.is_empty() && self.uris.is_none() {
            bail!("At least one of hosts or uris must be set on a Kong API")
        }

        let upstream_url = self.build_upstream_url(&service, &region.namespace);
        let (auth, authorization) = KongSource::build_auth(self.auth, self.authorization)?;

        let preserve_host = self.preserve_host.unwrap_or(true);

        Ok(Kong {
            name: name.to_string(),
            upstream_url: upstream_url,
            upstream_service: if preserve_host {
                Some(service.to_string())
            } else {
                None
            },
            internal: self.internal.unwrap_or_default(),
            publiclyAccessible: self.publicly_accessible.unwrap_or_default(),
            uris: self.uris,
            hosts,
            authorization,
            strip_uri: self.strip_uri.unwrap_or_default(),
            preserve_host,
            cors: self.cors,
            additional_internal_ips: self.additional_internal_ips.unwrap_or_default(),
            babylon_auth_header: self.babylon_auth_header,
            upstream_connect_timeout: self.upstream_connect_timeout,
            upstream_send_timeout: self.upstream_send_timeout,
            upstream_read_timeout: self.upstream_read_timeout,
            add_headers: self.add_headers,
            // Legacy authorization
            auth,
            // Distributed Tracing
            babylon_request_id: self.babylon_request_id.unwrap_or(true), // enabled by default for backwards compatibility.
            w3c_trace_context: self.w3c_trace_context.unwrap_or_default(),

            ip_rate_limits: self.ip_rate_limits.build(&())?,
            user_rate_limits: self.user_rate_limits.build(&())?,
        })
    }
/// Build a Kong from a KongSource, validating and mutating properties.
Build a Kong from a KongSource, validating and mutating properties.
Build a Kong from a KongSource validating and mutating properties .
fn build(self, params: &KongBuildParams) -> Result<Kong> {
        let KongBuildParams {
            region,
            service,
            name,
            kong,
        } = params;
        debug!("Building Kong API {} for {}", &name, &service);
        let hosts = self.build_hosts(&kong.base_url)?;
        if hosts.is_empty() && self.uris.is_none() {
            bail!("At least one of hosts or uris must be set on a Kong API")
        }
        let upstream_url = self.build_upstream_url(&service, &region.namespace);
        let (auth, authorization) = KongSource::build_auth(self.auth, self.authorization)?;
        let preserve_host = self.preserve_host.unwrap_or(true);
        Ok(Kong {
            name: name.to_string(),
            upstream_url: upstream_url,
            upstream_service: if preserve_host {
                Some(service.to_string())
            } else {
                None
            },
            internal: self.internal.unwrap_or_default(),
            publiclyAccessible: self.publicly_accessible.unwrap_or_default(),
            uris: self.uris,
            hosts,
            authorization,
            strip_uri: self.strip_uri.unwrap_or_default(),
            preserve_host,
            cors: self.cors,
            additional_internal_ips: self.additional_internal_ips.unwrap_or_default(),
            babylon_auth_header: self.babylon_auth_header,
            upstream_connect_timeout: self.upstream_connect_timeout,
            upstream_send_timeout: self.upstream_send_timeout,
            upstream_read_timeout: self.upstream_read_timeout,
            add_headers: self.add_headers,
            // Legacy authorization
            auth,
            // Distributed Tracing
            babylon_request_id: self.babylon_request_id.unwrap_or(true), // enabled by default for backwards compatibility.
            w3c_trace_context: self.w3c_trace_context.unwrap_or_default(),
            ip_rate_limits: self.ip_rate_limits.build(&())?,
            user_rate_limits: self.user_rate_limits.build(&())?,
        })
    }
fn build ( self , params : & KongBuildParams ) -> Result < Kong > { let KongBuildParams { region , service , name , kong , } = params ; debug ! ( " " name service ) ; let hosts = self . build_hosts ( & kong . base_url ) ? ; if hosts . is_empty ( ) && self . uris . is_none ( ) { bail ! ( " " ) } let upstream_url = self . build_upstream_url ( & service , & region . namespace ) ; let ( auth , authorization ) = KongSource :: build_auth ( self . auth , self . authorization ) ? ; let preserve_host = self . preserve_host . unwrap_or ( true ) ; Ok ( Kong { name : name . to_string ( ) , upstream_url : upstream_url , upstream_service : if preserve_host { Some ( service . to_string ( ) ) } else { None } , internal : self . internal . unwrap_or_default ( ) , publiclyAccessible : self . publicly_accessible . unwrap_or_default ( ) , uris : self . uris , hosts , authorization , strip_uri : self . strip_uri . unwrap_or_default ( ) , preserve_host , cors : self . cors , additional_internal_ips : self . additional_internal_ips . unwrap_or_default ( ) , babylon_auth_header : self . babylon_auth_header , upstream_connect_timeout : self . upstream_connect_timeout , upstream_send_timeout : self . upstream_send_timeout , upstream_read_timeout : self . upstream_read_timeout , add_headers : self . add_headers , // Legacy authorization auth , // Distributed Tracing babylon_request_id : self . babylon_request_id . unwrap_or ( true ) , // enabled by default for backwards compatibility. w3c_trace_context : self . w3c_trace_context . unwrap_or_default ( ) , ip_rate_limits : self . ip_rate_limits . build ( & ( ) ) ? , user_rate_limits : self . user_rate_limits . build ( & ( ) ) ? , } ) }
Build a Kong from a KongSource, validating and mutating properties.
Build a Kong from a KongSource validating and mutating properties .
self
params
&KongBuildParams
self
params
&KongBuildParams