mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 18:57:05 +08:00
feat: add support for pre-request scripts
Introduces `preRequestScript` and `postRequestScript` fields to the request model to store user-defined scripts. Implements a service using `flutter_js` to execute JavaScript pre-request scripts before a request is sent. The script can access and modify request data (like headers, body, URL) and environment variables. Adds bridging to forward JavaScript `console.log`, `console.warn`, and `console.error` calls to the Dart console for easier debugging
This commit is contained in:
@@ -27,6 +27,8 @@ _$RequestModelImpl _$$RequestModelImplFromJson(Map json) => _$RequestModelImpl(
|
||||
sendingTime: json['sendingTime'] == null
|
||||
? null
|
||||
: DateTime.parse(json['sendingTime'] as String),
|
||||
preRequestScript: json['preRequestScript'] as String? ?? "",
|
||||
postRequestScript: json['postRequestScript'] as String? ?? "",
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$RequestModelImplToJson(_$RequestModelImpl instance) =>
|
||||
@@ -39,6 +41,8 @@ Map<String, dynamic> _$$RequestModelImplToJson(_$RequestModelImpl instance) =>
|
||||
'responseStatus': instance.responseStatus,
|
||||
'message': instance.message,
|
||||
'httpResponseModel': instance.httpResponseModel?.toJson(),
|
||||
'preRequestScript': instance.preRequestScript,
|
||||
'postRequestScript': instance.postRequestScript,
|
||||
};
|
||||
|
||||
const _$APITypeEnumMap = {
|
||||
|
||||
Reference in New Issue
Block a user