def METHOD_NAME(temp_dir):
    os.makedirs(f'{temp_dir}/dir')
    os.makedirs(f'{temp_dir}/foo')
    with open(f'{temp_dir}/foo/index.html', 'w') as fooindex:
        fooindex.write('fooindex')
    # same action block
    assert 'success' in client.conf(
        {
            "listeners": {"*:7080": {"pass": "routes"}},
            "routes": [
                {
                    "action": {
                        "rewrite": "${request_uri}dir",
                        "share": f'{temp_dir}$uri',
                    }
                }
            ],
        }
    )
    resp = client.get()
    assert resp['status'] == 301, 'redirect status'
    assert resp['headers']['Location'] == '/dir/', 'redirect Location'
    # request_uri
    index_path = f'{temp_dir}${{request_uri}}/index.html'
    assert 'success' in client.conf(
        {
            "listeners": {"*:7080": {"pass": "routes"}},
            "routes": [
                {
                    "match": {"uri": "/foo"},
                    "action": {
                        "rewrite": "${request_uri}dir",
                        "pass": "routes",
                    },
                },
                {"action": {"share": index_path}},
            ],
        }
    )
    assert client.get(url='/foo')['body'] == 'fooindex'
    # different action block
    assert 'success' in client.conf(
        {
            "listeners": {"*:7080": {"pass": "routes"}},
            "routes": [
                {
                    "match": {"uri": "/foo"},
                    "action": {
                        "rewrite": "${request_uri}dir",
                        "pass": "routes",
                    },
                },
                {
                    "action": {
                        "share": f'{temp_dir}/dir',
                    }
                },
            ],
        }
    )
    resp = client.get(url='/foo')
    assert resp['status'] == 301, 'redirect status 2'
    assert resp['headers']['Location'] == '/foodir/', 'redirect Location 2'