Skip to main content

public-api

Exposes an internal API of the engine on a route.

Category SecurityAdd it to Route, Service, Consumer, Consumer group, Global rule, Plugin configEngine plugin public-apiPriority 501

What it does​

public-api serves an endpoint that a plugin registers for itself on a route you define. Examples are the sign-in endpoint of wolf-rbac and the endpoint that clears the cache of graphql-proxy-cache. URI names the endpoint's path, and left unset, the route's own path is used.

URI is a path a plugin registered, not a path of your backend. Only such a path answers, and only to the method its endpoint takes.

When to use it​

  • Partners sign in through wolf-rbac, and its sign-in endpoint must be reached at a path of your own choosing.
  • A team clears the cache of graphql-proxy-cache from its release job, through a route that only that job may call.
  • An endpoint a plugin registers should be reached only from the partner network, with ip-restriction on the same route.

Not for sending requests to a backend under another path — see proxy-rewrite (Rewrites the request URI, method, host and headers before proxying) or answering with a made-up response and no backend at all — see mocking (Answers requests with a mocked response instead of an upstream).

Set it up​

Serve the sign-in endpoint of wolf-rbac on a route of your own​

The route answers as the plugin's own endpoint would, so a sign-in needs a consumer that carries the wolf-rbac plugin.

Set URI to /apisix/plugin/wolf-rbac/login.

public-api · as the console saves it
{
"uri": "/apisix/plugin/wolf-rbac/login"
}

Things to know​

  • URI — Only a path a plugin registered answers, and only to the method it takes, so /status answers 404. Left unset, the route's own path is used.
  • AdvicePut an authentication plugin or ip-restriction on every route that carries public-api, unless the endpoint is meant for anyone.

Settings​

The fields as the console shows them, section by section.

URIuristring

Every plugin also has Enabled, Priority, Filter, Error response and Pre-function: see Plugin execution settings.

G8 dev · Apache APISIX® 3.19.0
Apache, Apache APISIX and APISIX are trademarks of The Apache Software Foundation.
Facts
Category
Security
Add it to
Route, Service, Consumer, Consumer group, Global rule, Plugin config
Engine plugin
public-api
Priority
501