📗
Janus Manual
  • Introduction
  • Installation
    • Docker
  • Quick Start
    • Authenticating
    • Add an endpoint
    • Modify (Update/Delete) an endpoint
    • Add Plugins
    • Authentication
    • Adding your API - File System
  • Clustering/HA
  • Proxy Reference
    • Terminology
    • Overview
    • Routing capabilities
    • Load Balacing
    • Request Host header
      • Using wildcard hostnames
      • The preserve_host property
    • Request URI
      • The strip_path property
      • The append_path property
    • Request HTTP method
    • Routing priorities
    • Conclusion
  • Plugins
    • Basic
    • Organization
    • Body Limit
    • Circuit Breaker
    • Compression
    • CORS
    • OAuth
    • Rate Limit
    • Request Transformer
    • Response Transformer
    • Retry
  • Auth
    • OAuth 2.0
  • Misc
    • Health Checks
    • Monitoring
    • Tracing
  • Known Issues
    • Stale HTTP Keep-Alive
  • Upgrade Notes
    • 2.x to 3.x
    • 3.6.x to 3.7.x
Powered by GitBook
On this page
  • 1. Adding a new endpoint
  • 2. Verify that your API has been added
  • 3. Forward your requests through Janus

Was this helpful?

  1. Quick Start

Add an endpoint

The main feature of an API Gateway is to proxy requests to different services, so let's do this.

1. Adding a new endpoint

Now that you are authenticated, you can send a request to /apis to create a proxy.

Create an example.json file containing your endpoint configuration:

{
    "name" : "my-endpoint",
    "active" : true,
    "proxy" : {
        "listen_path" : "/example/*",
        "upstreams" : {
            "balancing": "roundrobin",
            "targets": [
                {"target": "http://www.mocky.io/v2/595625d22900008702cd71e8"}
            ]
        },
        "methods" : ["GET"]
    }
}

And now let's add it to Janus:

http -v POST localhost:8081/apis "Authorization:Bearer yourToken" "Content-Type: application/json" < example.json

curl -X "POST" localhost:8081/apis -H "Authorization:Bearer yourToken" -H "Content-Type: application/json" -d @example.json

This will create a proxy to http://www.mocky.io/v2/595625d22900008702cd71e8 (which is a fake api) when you hit Janus on GET /example.

2. Verify that your API has been added

You can use the REST API to query all available APIs and Auth Providers. Simply make a request to /apis:

http -v GET localhost:8081/apis "Authorization:Bearer yourToken" "Content-Type: application/json"

curl -X "GET" localhost:8081/apis -H "Authorization:Bearer yourToken" -H "Content-Type: application/json"

3. Forward your requests through Janus

Issue the following request to verify that Janus is properly forwarding requests to your API. Note that by default Janus handles proxy requests on port :8080:

A successful response means Janus is now forwarding requests made to http://localhost:8080 to the elected upstream target (chosen by the load balancer) that we configured in step #1, and is forwarding the response back to us.

PreviousAuthenticatingNextModify (Update/Delete) an endpoint

Last updated 4 years ago

Was this helpful?

http -v GET

curl -vX "GET"

we'll learn how to modify existing endpoint.

http://localhost:8080/example
http://localhost:8080/example
Next