Merging
Couper supports merging of blocks and attributes from multiple configuration files (see Basic Options of Command Line Interface).
- Merging
 - General Rules of Merging
 - Merging of 
serverBlocks - Merging of 
definitionsBlocks - Merging of 
defaultsBlocks - Merging of 
settingsBlocks 
General Rules of Merging
When merging, all attributes (except environment_variables in the defaults block) replace existing attributes with the same name, if any, otherwise they are added.
Blocks that cannot have labels (eg. cors, files etc.) replace existing blocks with the same name, if any, otherwise they are added.
Blocks with optional labels (eg. server, api, spa, files etc.) are merged recursively with blocks with the same label (blocks without a label are merged with blocks with the same name and no label in each context), if any, otherwise they are added. Only one unlabeled block of the same type is allowed in each context (eg. api blocks in a server block).
Blocks with required label (eg. endpoint) replace existing blocks with the same name and label in each context, if any, otherwise they are added.
Blocks with (optional) multiple labels (eg. error_handler) replace existing blocks with identical labels, if any, otherwise they are added.
Currently, here is no way to remove an attribute or a block from the configuration.
Merging of server Blocks
- When 
serverblocks are merged:- All attributes replace existing attributes with the same name, if any, otherwise they are added.
 - The 
corsblocks replace existing blocks with the same name, if any, otherwise, they are added. - All 
endpointblocks replace existing blocks with the same label, if any, otherwise they are added. 
 - When 
spaorfilesblocks are merged:- All attributes replace existing attributes with the same name, if any, otherwise they are added.
 - The 
corsblock replaces existingcorsblock, if any, otherwise a newcorsblock is added. 
 - When 
apiblocks are merged:- All attributes replace existing attributes with the same name, if any, otherwise they are added.
 - The 
corsblock replaces existingcorsblock, if any, otherwise a newcorsblock is added. - All 
endpointblocks replace existing blocks with the same label, if any, otherwise they are added. - All 
error_handlerblocks replace existing blocks with identical labels, if any, otherwise they are added. 
 
Note: An error_handler block cannot be replaced in or added to an endpoint block. Therefore, the endpoint block must be completely replaced.
Merging of definitions Blocks
- The 
definitionsblocks are merged recursively, if any, otherwise a newdefinitionsblock is added. - All blocks inside a 
definitionsblock replace existing blocks with the same name and label. 
Merging of defaults Blocks
- The 
defaultsblocks are merged recursively, if any, otherwise a newdefaultsblock is added. - All attributes inside a 
defaultsblock (exceptenvironment_variables) replace existing attributes with the same name, if any, otherwise they are added. - Single values of an 
environment_variablesattribute replace existing values with the same key, if any, otherwise they are added. 
Merging of settings Blocks
- The 
settingsblocks are merged recursively, if any, otherwise a newsettingsblock is added. - All attributes inside a 
settingsblock replace existing attributes with the same name, if any, otherwise they are added.