Giter Club home page Giter Club logo

api_example's Introduction

Responsabilities:

cmd/nethegateapi/main.go starts the application/service

internal/openAPIHandlers : These are the handlers generated by OpenAPI. They route requests to the service (eg createNewUser, )

internal/nethGateAPI: This is the core of the service. It is responsible for handling the requests, for example generating a new API key for users, syncing this with Kong, and storing the users data in a local DB

internal/kongAdminAPI: we need this to sync our users data with Kong (ie integrate with Kong Admin API)

internal/juno: this is just to make RPC calls to Juno

internal/db: this is to store the user data in a local data base persistently

Structure:

internal/openAPIHandlers imports internal/nethGateAPI

internal/nethGateAPI imports internal/kongAdminAPI, internal/juno, internal/db

Other notes:

Handling New Consumers:

  1. Registration Through Your Handlers : When a new user (consumer) registers via your API, your handler for user registration will process this.
  2. API Key Generation : As part of this registration process, your system will generate an API key for the new user.
  3. Sync with Kong : You then use Kong's Admin API to register this user as a consumer in Kong and associate the generated API key with them. This step is crucial for Kong to recognize and validate the API key in future requests.
  4. Save API Key in Database : Store the API key and any other relevant user information in your database.
  5. Return API Key to User : Respond to the user with their API key, which they will use for subsequent requests.

Handling Requests from Existing Consumers:

  1. API Requests with API Key : Existing users send requests to your API endpoints exposed by Kong, including their API key for authentication.
  2. Kong Gateway Filters Traffic : Kong processes these requests first, validating the API keys and applying any other configured filters like rate limiting.
  3. Routing to Your Application : If the request is valid, Kong routes it to your application.
  4. Application Processes Request : Your application then processes the request. Since it's about interacting with a blockchain client, this step involves sending transactions to the blockchain, querying data, etc.
  5. Responding to User : After processing, your application sends the response back through Kong to the user.

api_example's People

Contributors

rianhughes avatar

Watchers

 avatar

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.