How to add an endpoint to a plugin?

Hello there,

I found the solution. It is very confusing that the original file generated by generator looks like:

module.export = [
      {
        method: 'GET',
        path: '/',
        handler: 'myController.index',
        config: {
          policies: [],
        },
      },
...
]

Also confusing in my opinion is, that the generator, if you create an endpoint for a plugin does it under /src/plugin directly.

The solution is simple.

I found this post here https://forum.strapi.io/t/permissions-for-strapi-plugin/19438/9.

So I changed my router file (src/plugins/server/routers/index.js) in that way:

module.exports = {
  admin: {
    type: 'admin',
    routes: [
      {
        method: 'GET',
        path: '/',
        handler: 'myController.index',
        config: {
          policies: [],
        },
      },
   ...
  },
  'content-api': {
    type: 'content-api',
    routes: [
      {
        method: 'GET',
        path: '/do-job-with-description/:description',
        handler: 'myController.doJobWithDescription',
        config: {
          policies: [],
        },
      },
    ]
  }
};

And now I can use an external tool also. Please notice: My Strapi backend runs behind a firewall in a save virtual enviroment and no one outside can use it. So, if you want to serve data to outside, you have to set the policies.

regards,
Sven