Code Monkey home page Code Monkey logo

Comments (7)

stevehu avatar stevehu commented on May 10, 2024 1

The final decision is to put it into swagger-codegen to inject security for server info and an endpoint to specification in the preprocessing phase. It works pretty well and this can be a common ways to add other common endpoints in the feature. The server info handler is renamed so that it can match the same name generated. The import statement is change the template to point the handler to the one in light-java instead.

from light-4j.

AmaranthLIS avatar AmaranthLIS commented on May 10, 2024

Yes, if project generated by swagger we can't add other handlerProviders like info/healthy ...
Even if add new handlerProvider to com.networknt.server.HandlerProvider
But it is so need!

from light-4j.

stevehu avatar stevehu commented on May 10, 2024

Two months ago, I have tried to inject the a separate path with /server/info and a specific scope to control who can access it in SwaggerHandler. It is working but I just don't feel good about it. One problem with this is the final url is dynamic as the API/service swagger spec might have v1 or v2 as base path and it is not predictable. We need a static server info url so that it can be called from portal. I am working on the service registry and discovery now and hoping to let the server to send notification to portal once it is up and running with full path of server info url just like it register itself with Consul or Zookeeper. The other way to work our is inject a handler into the call chain to bypass swagger, validation etc. It is doable but pretty messy as call chain is dynamic per API/service. I am open to any ideas or recommendations at the moment and will come back to this issue soon as this is needed for production like you said.

from light-4j.

AmaranthLIS avatar AmaranthLIS commented on May 10, 2024

In this cause i really don't know how better it do...
I can offer this way: add PATH an exception for swagger-validation which get from config.
HandlerProvider is manually added routing (for example /server/info).

from light-4j.

stevehu avatar stevehu commented on May 10, 2024

This is the approach I was taking but due to the dependency of base path in the original swagger spec, the server/info might have /v1 or /v2 or some other prefixes. Also, you don't need to by pass the validation and security as when you inject something the scope and other validation constraints will be in. I am hoping I will have answers once service registry is completed and see if we can let server to register the server/info endpoint on consul or zookeeper.

from light-4j.

stevehu avatar stevehu commented on May 10, 2024

Tried to convert ServerInfoHandler to middleware so that it can be put into the middleware chain. It works but it doesn't make sense that every request must go through ServerInfoHandler to check it the uri is matched. It is too much overhead just for this simple common API.

from light-4j.

stevehu avatar stevehu commented on May 10, 2024

The next step is to secure the endpoint so that only light-portal can access it.

from light-4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.