title: Data Loader keywords:
The data loader is an abstraction of the data import and export functionality under different specification definitions.
Based on it, developers can easily implement the ability to export APISIX data entities to generate different data files, and parse the data files and convert them into APISIX data entities for import into APISIX.
type Loader interface {
// Import accepts data and converts it into entity data sets
Import(input interface{}) (*DataSets, error)
// Export accepts entity data sets and converts it into a specific format
Export(data DataSets) (interface{}, error)
}
Implement the above functions to complete the data conversion between Raw data format and DataSets data set, APISIX Dashboard will use DataSets data format as the intermediate format for importing and exporting according to it.
Developers can look at the code in api/internal/handler/data_loader/loader/loader.go for the definition of the DataSets structure and the Data Loader interface.
Extending the data loader is simple and requires some development in the backend and frontend.
Create a structure that implements the above interface, which contains two parts.
[]byte
uploaded by the user to DataSets structure api/internal/handler/data_loader/loader/openapi3/import.goAdds a new item to the data loader list of the import and export handler.
Adds the previously created data loader to the frontend selector. Refer to this for more details.
:::note When you implement a data loader that requires partial input of custom parameters, you can create a form for it to enter data. Refer to this for more details. :::