📗
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. Update existing endpoint
  • 3. Delete existing endpoint

Was this helpful?

  1. Quick Start

Modify (Update/Delete) an endpoint

As your infrastructure grows and changes you need to modify existing endpoints configurations and delete unused one. In this section we'll add one more endpoint, like we did in the last section, will make some changes to it and then remove it.

1. Adding a new endpoint

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

Create an example-modify.json file containing your endpoint configuration:

{
    "name" : "my-endpoint-to-modify",
    "active" : true,
    "proxy" : {
        "listen_path" : "/temporary/*",
        "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-modify.json

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

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

By this point this is exactly what we did in the previous section, when we added first endpoint.

You can make sure that the configuration is created using an API, same as we did before

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"

And that it proxies requests to a desired destination, again, same as we did previously

2. Update existing endpoint

Updating existing endpoint is almost the same as creating new one except for the method and api endpoint used.

First, let's modify a file containing endpoint configuration and change active to false to deactivate existing endpoint, so the resulting file will look like this:

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

To modify an endpoint we'll use the same /apis REST API endpoint, but with the PUT method and endpoint name, that is set in the name field, as resource:

http -v PUT localhost:8081/apis/my-endpoint-to-modify "Authorization:Bearer yourToken" "Content-Type: application/json" < example-modify.json

curl -X "PUT" localhost:8081/apis/my-endpoint-to-modify -H "Authorization:Bearer yourToken" -H "Content-Type: application/json" -d @example-modify.json

Make sure that the configuration is modified

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"

And that it is not proxying requests anymore

3. Delete existing endpoint

Some endpoints become outdated and it does not make sense to store all of them in non-active state, so we can simply remove them.

To modify an endpoint we'll use the same /apis REST API endpoint, but with the DELETE method and endpoint name, that is set in the name field, as resource:

http -v DELETE localhost:8081/apis/my-endpoint-to-modify "Authorization:Bearer yourToken"

curl -X "DELETE" localhost:8081/apis/my-endpoint-to-modify -H "Authorization:Bearer yourToken"

Make sure that the configuration is removed

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"

PreviousAdd an endpointNextAdd Plugins

Last updated 4 years ago

Was this helpful?

http -v GET

curl -vX "GET"

http -v GET

curl -vX "GET"

we'll learn how to add plugins to our endpoint.

http://localhost:8080/temporary
http://localhost:8080/temporary
http://localhost:8080/temporary
http://localhost:8080/temporary
Next