What is webhook?

1. What is WebHook?
  Webhooks api is a concept, is one of the micro-services api use paradigm, also known as reverse api, namely: the front end does not take the initiative to send a request, entirely pushed by the back-end. For example, commonly used, such as your friend, sending a circle of friends, the rear end of this news pushed to all other friends of the client, it is a typical scene of Webhooks.

In simple terms, WebHook is a receiving HTTP POST (or GET, PUT, DELETE) of the URL. A realization of WebHook API provider that is a good URL will send a message to this configuration when the event occurred. And request - response type is different use WebHooks, you can receive real-time changes.

This is a kind of a client - server model reversal, in the conventional method, the client requests data from the server, and the server provides the data to the client (client in the pull-up data). In Webhook paradigm, the server updates the resource needs to be provided, then automatically sent to the client as an update (in the push data server), the client is not the requester, but passive receiver. This control can be used to facilitate inversion relationship Many communication request otherwise require more complex and continuously polling request on a remote server. By simply receiving resources rather than directly send a request, we can update remote code library easily assign resources, and even integrate it into existing systems needed to be updated API endpoints and related data, the only drawback is the initial establishment difficult.

2. The main purpose of
  updating client, providing updated data specified in the new or updated resource.

3. Common usage scenarios webhooks
  do third-party platform for the transfer of the right to inspection, no landing and other front-end interface scene, or a scene of strong security requirements such as payment, suitable for data Webhooks active push. When that white is unable to participate in the front, or front-end security because the problem is not fit to participate, that is Webhooks scene. Obviously Webhooks Http is not a substitute for, but is indeed a new front and rear end of the interaction.

If the client wants to listen to a long-term task of the state, to do the normal way api calls, you must constantly have in rotation server to get the current state; there is no need to use webhook rotation, through the API can determine whether changes, if changed only need to wait for the server to push information over, and then the client will be updated. git webhook actually apply in this regard.

4. Instructions
  1, webhook after your application, the data no longer of interest by requesting the data transmission. This means that if your application problems, data will be lost. Many webhook will respond to treatment, an error occurs if the program will retransmit the data. If your application is still processing the request and return an error, your application will receive duplicate data.

2, webhook will issue a large number of requests, this will cause your application blocking. Make sure your application can handle these requests.

Published 54 original articles · won praise 28 · views 4210

Guess you like

Origin blog.csdn.net/qq_37174887/article/details/104043781