How can I monitor the interface api, call frequency, and sensitive request parameters of the laravel framework?

Source: Internet
Author: User
{Code...} Could you tell me how to refine the interface monitoring? thank you?
Http://test.phpmethod: postparam: {"name": "12333", "id": "2"} conditions to be monitored 1. if you create or update data, you need to monitor 2. to modify the price, you need to monitor it, and then send an email to inform the interface owner. "Someone has modified the product price." Currently, the request: uri method ip port record param: request parameter result response interface user_id interface requester

How can I refine this interface monitoring? thank you?

Reply content:
Http://test.phpmethod: postparam: {"name": "12333", "id": "2"} conditions to be monitored 1. if you create or update data, you need to monitor 2. to modify the price, you need to monitor it, and then send an email to inform the interface owner. "Someone has modified the product price." Currently, the request: uri method ip port record param: request parameter result response interface user_id interface requester

How can I refine this interface monitoring? thank you?

I will give a simple answer, and the subject will check the relevant documents on his own.

  1. Interface frequency limit

    • Laravel 5.2 and abovethrottleMiddleware control

    • Laravel 5 can implement https://github.com/GrahamCampbell/Laravel-Throttle with third-party extension packages

  2. Interface update can be directly monitoredEloquent event, Event document address https://laravel-china.org/docs/5.1/eloquent#events

    • For example, listeningUser's savingEvent, event judgmentUserIs the nickname modified? the brief code is as follows:

    User: saving (function (User $ user) {// determines whether the nickname is modified if ($ user-> isDirty ('Nick _ name ')) {$ old_nick_name = $ user-> getOriginal ('Nick _ name'); // original value $ new_nick_name = $ user-> nick_name; // Mail with the new value :: raw ("$ user-> name: Change nickname $ old_nick_name to $ new_nick_name"); // send email }});
  3. Request parameters, which can be defined for each interfaceRequestParameter rulesrules, Unified interception processing

Cannot be implemented in the code? If you consider performance, you can use the message queue.
Or add logs to allow OP to monitor logs and match emails.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.