Configurazioni di esempio Server - eliguori88/restbrain-server Wiki

Configurazione multi-server(bind_address)

In questo esempio vengono creati due server che ascoltano su ip diversi, sulla stessa porta. Ognuno con un api che risponde a /ping. Mostra come è possibile creare diversi server che rispondano su ip diversi con api diverse.

<?xml version="1.0" encoding="UTF-8"?>
<!-- <!DOCTYPE note SYSTEM "Note.dtd"> -->
<restbrain>
    <security_profiles>
        <security_profile>
            <name>public</name>
            <white_list enabled='0'></white_list>
            <black_list enabled='0'></black_list>
        </security_profile>
    </security_profiles>

    <servers>
        <server>
            <name>Local server</name>
            <listen_port>80</listen_port>
            <bind_address>127.0.0.1</bind_address>
            <connection_timeout>10</connection_timeout>
            <max_connections>1</max_connections>
            <max_connections_per_host>0</max_connections_per_host>
            <on_path_not_found>404</on_path_not_found>

            <apis>
                <api path="/ping" method="GET" security_profile="public">
                    <logic>
                        <block
                            class='it.gexy.restbrain.server.core.logic.blocks.LBText'>
                            <text>Local OK</text>
                        </block>
                        <block
                            class='it.gexy.restbrain.server.core.logic.blocks.http.LBResponce'>
                        </block>
                    </logic>
                </api>
            </apis>
        </server>

        <server>
            <name>Public server</name>
            <listen_port>80</listen_port>
            <bind_address>192.168.1.100</bind_address>
            <connection_timeout>10</connection_timeout>
            <max_connections>1</max_connections>
            <max_connections_per_host>0</max_connections_per_host>
            <on_path_not_found>404</on_path_not_found>

            <apis>
                <api path="/ping" method="GET" security_profile="public">
                    <logic>
                        <block
                            class='it.gexy.restbrain.server.core.logic.blocks.LBText'>
                            <text>Public OK</text>
                        </block>
                        <block
                            class='it.gexy.restbrain.server.core.logic.blocks.http.LBResponce'>
                        </block>
                    </logic>
                </api>
            </apis>
        </server>
    </servers>
</restbrain>

Configurazione del default path

In questo esempio viene definito un server con un API di test e la defautl API in caso venga ricevuta una richiesta con path inesistente

<?xml version="1.0" encoding="UTF-8"?>
<restbrain>
    <security_profiles>
        <security_profile>
            <name>public</name>
            <white_list enabled='0'></white_list>
            <black_list enabled='0'></black_list>
        </security_profile>
    </security_profiles>

    <servers>
        <server>
            <name>Local server</name>
            <listen_port>80</listen_port>
            <bind_address>*</bind_address>
            <connection_timeout>10</connection_timeout>
            <max_connections>1</max_connections>
            <max_connections_per_host>0</max_connections_per_host>
            <on_path_not_found>default</on_path_not_found>

            <apis>
                <api path="/ping" method="GET" security_profile="public">
                    <logic>
                        <block
                            class='it.gexy.restbrain.server.core.logic.blocks.LBText'>
                            <text>Local OK</text>
                        </block>
                        <block
                            class='it.gexy.restbrain.server.core.logic.blocks.http.LBResponce'>
                        </block>
                    </logic>
                </api>
                
                <api path="/*" method="GET" security_profile="public">
                    <logic>
                        <block
                            class='it.gexy.restbrain.server.core.logic.blocks.LBText'>
                            <text>default</text>
                        </block>
                        <block
                            class='it.gexy.restbrain.server.core.logic.blocks.http.LBResponce'>
                        </block>
                    </logic>
                </api>
            </apis>
        </server>
    </servers>
</restbrain>