Bỏ qua, đến nội dung

Tham chiếu API

Tổng quan endpoints

EndpointMethodMô tả
customRequests:sendPOSTResolve template và gửi HTTP request đến URL đích
customRequests:listByCurrentRoleGETLấy danh sách request mà role hiện tại được phép dùng
customRequests:getGETLấy chi tiết một cấu hình request
customRequests:createPOSTTạo cấu hình mới (admin)
customRequests:updatePUTSửa cấu hình (admin)
customRequests:destroyDELETEXóa cấu hình (admin)
customRequests:listGETLiệt kê tất cả cấu hình (admin)

customRequests:send

Endpoint chính — resolve template variables rồi gửi HTTP request.

Method: POST

Request body:

Tham sốKiểuBắt buộcMô tả
keystringKhóa định danh của custom request
currentRecordobjectKhôngDữ liệu bản ghi hiện tại (client gửi lên)
$nFormobjectKhôngDữ liệu form hiện tại

Luồng xử lý server:

  1. Đọc cấu hình từ bảng customRequests theo key.
  2. Kiểm tra role hiện tại có quyền sử dụng (qua customRequestsRoles).
  3. Resolve template variables trong URL, headers, body — thay thế biến currentRecord, currentUser, $nForm bằng giá trị thực (template parsing).
  4. Gửi HTTP request đến URL đích qua axios.
  5. Ghi log kết quả vào file logger.
  6. Trả response từ hệ thống đích về client.

Response: Trả về response body từ hệ thống đích (pass-through).

customRequests:listByCurrentRole

Lấy danh sách request mà user hiện tại được phép sử dụng (dựa trên role).

Method: GET

Response: Mảng cấu hình request đã lọc theo role.

customRequests:get

Method: GET

Query params:

Tham sốKiểuMô tả
filterByTkstringKey của request cần lấy

Response: Object cấu hình request.

Database schema

Bảng customRequests

CộtKiểuMô tả
keystring (PK)Khóa định danh duy nhất
optionsJSONCấu hình request: url, method, headers, body, params
rolesbelongsToManyQuan hệ M2M qua bảng customRequestsRoles
createdAtdatetimeThời gian tạo
updatedAtdatetimeThời gian cập nhật

Bảng customRequestsRoles (junction)

CộtKiểuMô tả
customRequestKeystring (FK)Tham chiếu customRequests.key
roleNamestring (FK)Tham chiếu roles.name

ACL

QuyềnLoạiMô tả
ui.*SnippetCho phép truy cập UI quản lý custom requests
customRequests:sendActionUser đã đăng nhập — gửi request
customRequests:listByCurrentRoleActionUser đã đăng nhập — lấy danh sách
customRequests CRUDResourceChỉ admin — quản trị cấu hình