Tạo endpoint api khách hàng

Bổ sung cấu hình API

I. Cấu hình DB

  1. Vào DB VTTECHDOC

  2. Ở Table VTT_API_Endpoints tạo 1 dòng dữ liệu API Column Code không được trùng.

  3. Truy cập

  4. Dùng Code vừa tạo ở bước 2:

// Paste vào hàm Main
Console.WriteLine(EncryptString(, SemiSecret)); // Lấy mã vừa sinh là Code'

II. Vào source API_SMSNoti

  1. Vào models Models/APIPerCode

  2. Bổ sung Code vừa tạo biến APIPerCodeKey Theo cấu trúc

// 
// Trong đó: 
// Location là group Endpoint
// GetCommune là tên định danh của endpoint
// Code' là code đã được encrypt ở bước I.4

private static Dictionary<string, Dictionary<string, string>> APIPerCodeKey = new Dictionary<string, Dictionary<string, string>>
{
    { "Location", new Dictionary<string, string>
        {
            { "", "Code'" },// KEY 
        }
    },
};

III. Ở API_SMSNoti tạo API

  1. Tạo 1 controller ( Nếu chưa có )

  2. Tại Route add Middleware để kiểm tra client có được sử dụng API không.

// Example
[Route("GetSip")]
[ClientAttribute("Location", "GetCommune")]

Last updated