Example #1
0
        public async Task <bool> IsRegistered()
        {
            try
            {
                var response = await KongHttpClient.GetAsync($"/services/{KongServiceSettings.Name}");

                return(response.StatusCode == System.Net.HttpStatusCode.OK);
            } catch
            {
                return(false);
            }
        }
Example #2
0
        public async Task <bool> IsRunning()
        {
            try
            {
                var response = await KongHttpClient.GetStringAsync("/");

                return(response.Length > 0);
            }
            catch
            {
                return(false);
            }
        }
Example #3
0
        public async Task Register()
        {
            if (await IsRegistered())
            {
                return;
            }

            await KongHttpClient.PostAsJsonAsync("/services", new
            {
                name = KongServiceSettings.Name,
                url  = $"https://{ServiceSettings.LocalUrl}:443"
            });

            await KongHttpClient.PostAsJsonAsync($"/services/{KongServiceSettings.Name}/routes", new
            {
                preserve_host = true,
                paths         = new List <string>()
                {
                    $"/{ServiceSettings.Path}"
                }
            });
        }