Ocelot: How to add check helth method to my Gateway project .net core

Created on 29 Sep 2018  ·  3Comments  ·  Source: ThreeMammals/Ocelot

Feature

Is there any way to enforce requests to a project controller with Ocelet (my GatewayApi project) for example create the check url to register in the Consul.
URL to check the integrity of my GatewayAPI in the .NET core.

When I make any request for a controller in my GatewayApi project, I always get an error with the message "Could not find the downstream route to the path"

Steps to Reproduce the Problem

  1. Create a project web.api C# .net core
  2. Add a Controller (InfoController) with one method Foo (retrun date time)
  3. Add reference for Ocelot
  4. Make Request with postman, webbrowser to localhost:9000;

Specifications

  • Version: last version Ocelot
  • Platform: .net core
  • Subsystem:
question

Most helpful comment

@lucianoscastro 网关的健康检查,可以在预留中间件里添加健康检查地址,不过一般这个地址都是给nginx使用的

                var conf = new OcelotPipelineConfiguration()
                {
                    PreErrorResponderMiddleware = async (ctx, next) =>
                    {
                        if (ctx.HttpContext.Request.Path.Equals(new PathString("/")))
                        {
                            await ctx.HttpContext.Response.WriteAsync("ok");
                        }
                        else
                        {
                            await next.Invoke();
                        }
                    }
                };
                app.UseOcelot(conf).Wait();

All 3 comments

@lucianoscastro 网关的健康检查,可以在预留中间件里添加健康检查地址,不过一般这个地址都是给nginx使用的

                var conf = new OcelotPipelineConfiguration()
                {
                    PreErrorResponderMiddleware = async (ctx, next) =>
                    {
                        if (ctx.HttpContext.Request.Path.Equals(new PathString("/")))
                        {
                            await ctx.HttpContext.Response.WriteAsync("ok");
                        }
                        else
                        {
                            await next.Invoke();
                        }
                    }
                };
                app.UseOcelot(conf).Wait();

@lucianoscastro "Could not find the downstream route to the path" means that Ocelot cannot find your anything in json configuration for your requested route.

Can you share your configuration json?

Ocelot doesn't do health checks at the moment. I would suggest using Consul if you want that functionality.

I think the idea behind this is to add a healthcheck endpoint to the ocelot gateway itself, so that you can check that it's up and running.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mjrousos picture mjrousos  ·  6Comments

FerAguilarR93 picture FerAguilarR93  ·  6Comments

ioritzalberdi picture ioritzalberdi  ·  5Comments

Marusyk picture Marusyk  ·  3Comments

FerAguilarR93 picture FerAguilarR93  ·  3Comments