I don't understand how to create a route with Strapi 4

change post.js in routes folder

const { createCoreRouter } = require('@strapi/strapi').factories;
const defaultRouter = createCoreRouter('api::post.post');

const customRouter = (innerRouter, extraRoutes = []) => {
  let routes;
  return {
    get prefix() {
      return innerRouter.prefix;
    },
    get routes() {
      if (!routes) routes = innerRouter.routes.concat(extraRoutes);
      return routes;
    },
  };
};

const myExtraRoutes = [
  {
    method: 'POST',
    path: '/api/posts/:id/comments',
    handler: 'api::post.post.comments',
  },
];

module.exports = customRouter(defaultRouter, myExtraRoutes);

above code adds new route to your existing post api .

change post.js in controllers folder

'use strict';

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::post.post', ({strapi}) => ({
    comments: async (ctx) => {
       // following variable will get url `id` param value.
        const id = ctx.params['id']
    }
}));

One Important thing : If you are interacting with this api then please generate api token or give permission to existing api token with token type (access) as Full access otherwise you will get Forbidden Error .