FPublisher
Web-����������: ���� ������
������������ PHP
hw_api_attribute->value
(No version information available, might be only in CVS)
hw_api_attribute->value � Returns value of the attribute
��������
Gets the value of the attribute.
������������ ��������
Returns the value, as a string.
�������� �����
��������� �����������:
���������� �� �����
��������� 14 ����� 2020 ����
�p���� Genesis (�� ��p��p������� ��p������)
��������� �� ������ � Vim
��������� 05 ������� 2020 ����
Vim �������� ������ ��������, �� ������ � ��� �� ������ ��������.
�������� ���� ����� ��������������� �����-�� ���� �������� ��� ������ crontab, ��� ������ ��������� ������ � viv �����.
������: Error: Cannot find a val >��������� 13 �������� 2020 ����
���� ��������� ������ �� centos 5 ����
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/
Linux Optimization
��������� 30 ���� 2012 ����
XXXIX. ������� Hyperwave API
Hyperwave ��� ���������� IICM � Graz. �� ��������� ��� Hyper-G � ������ �������� �� Hyperwave ��� ���������������� (��������� �����, ��� ���� � 1996).
Hyperwave ��� �� ���������� ���������. ������� ������, 5.5, �������� �� www.hyperwave.com. ����� ��������� ��������� ������ � ������������ �������� ������������� (30 ����).
Hyperwave ��� �������������� �������, ����������� database (HIS, Hyperwave Information Server). ��� ������������� �� �������� � ������������ ����������. ���������� ����� ���� ����� ���� ������, ������� ����� ����������� � �����. ������ �������� �������������� ������� �������. ������ �������/object record �������� ���������� ���������. ���������� ��� ������ ���������, ������� ����� ���� �������� �������������. ��������� �������� ������ ��������������� Hyperwave-��������, ������ ����� ���������������� �������������.
� 2001 �. �������� Hyperwave SDK. �� ������������ Java, JavaScript � C++. ������ ���������� PHP ���������� �� ���������� C++. ����� ������������ ��������� hwapi � PHP, �� ������ ������� ���������� Hyperwave SDK � ���������������� PHP � ������ —with-hwapi= .
API, ��������������� ����������� HW_API, �������� ��������� ��������-���������������. �� ����� ����� �� ��������� C++ Hyperwave SDK. �� ������� �� ��������� �������.
��������� ������� ������ ����� HW_API_String , HW_API_String_Array , etc., ������� ������� � Hyperwave SDK, �� �����������, ��������� PHP ����� ��� ��� ����������� ������.
������ ����� ����� �����, ��� �������� ��������� ����� ��� �������� �� Hyperwave SDK. �������� ���������� ����� ������� ���������� �� ���� ������ ���������� PHP � ���������� C++ API ������ HW SDK. ������ �������� ��������� ����������, ��� ��� ���������� � ������������� ������ � ���������� ��� ���� ��������. ����� ������ ��������� ������, ������������������� � HW SDK. ����� ��������� ����������� ����. ���� ���������� ������ ���������, ��� ����� ���������������, ���� ��� ����������.
objectIdentifier — ��� ��� id �������, ��������, «rootcollection», «0x873A8768 0x00000002».
parentIdentifier — ��� ��� id �������, ������� ��������� ������������.
object — ��������� ������ HW_API_Object.
parameters — ��������� ������ HW_API_Object.
version — ������ �������.
mode — ������������� �������� — ������ ���������� ��������.
attributeSelector — ������ �����, ������ �� ������� �������� ��� ��������. ��� ������������, ���� �� ������������ ������ ������� � ������ �������� ��������� ��������.
objectQuery — ������ �� ����� ������������ ������� �� ������ ��������. ������������ ��� ���������� ���������� ��������, ���������� ��������� ����� hw_api->children() ��� hw_api->find() .
���������� � Apache �, ��������, ������� ��������� ��� ������� � ������ Hyperwave Modul, ������� ��� ������ ����������� ��� ���������� � Hyperwave Server.
����� �����
��� ������ ���� ������������� ����������? ���, ��� ��������� ������� ��� ��������. � ���� ������ �� ��� ����� ���������, ���� ����������� �����? ��� �������� ���� ��������, ��� ����� ����������, ������� ��������? � ���������, � ������ � � ���������� �����. ���������� �� ����������� ���� � ���� Facebook � �� ��������� ���������������� ������� ������������ ������������ � ����������� ��������� ������ � ������ ���������� �������, ����������� � ������ ������������ ������ ���������� � ���������� � ���������� �����.
����� ������� ����� ����������� ���������� � ������������� �������� �� ���� �� ������, � ����� ������������ ���� ������.
��� ������� �������� �������� ��������? ������ �����, ��������������� ������������� �������. �� ������ ����� ����������� ������� ��� �������� � �������� � ���������� �����, �������� �������� �� ������� ��� �������������� � ��������������, �������� �� �������, �������� ������ ������ � �������� �����.
����� ������� ��� ��������������� � ���� ���������� ����� � ������������� ��������, ������ ��� �������� � ���� � ������������ ��� �� �����������, ������� ��� �������������. �������� ����� ������� � ��������� �����, ��� ��������� ��� ����������, � ��������� ������� ���������� ��� ��� ���� �������� ����� ��� ����������� ������� �������� ������� ������ ������ ��� ���.
������������� � ASP.NET Web API 2 � ������� ��������� Attribute Routing in ASP.NET Web API 2
������������� �������� ��� ���-API ������������ URI � ���������. Routing is how Web API matches a URI to an action. ���-API 2 ������������ ����� ��� �������������, ���������� ������������� � ������� ���������. Web API 2 supports a new type of routing, called attribute routing. ��� � ������������ ��������, ������������� � ������� ��������� ���������� �������� ��� ����������� ���������. As the name implies, attribute routing uses attributes to define routes. ������������� � ������� ��������� ������������� ������� �������� ��� ���� URI � ���-API. Attribute routing gives you more control over the URIs in your web API. �������� ����� ����� ������� URI, ������� ��������� �������� ��������. For example, you can easily create URIs that describe hierarchies of resources.
����� ������ ����� �������������, ���������� �� ������ ���������� �������������, ��-�������� ��������� ��������������. The earlier style of routing, called convention-based routing, is still fully supported. �� ����� ���� ����� �������� ��� ������� � ��� �� �������. In fact, you can combine both techniques in the same project.
� ���� ������� ��������, ��� �������� ������������� ��������� � ����������� ��������� ��������� ��� ������������� � ������� ���������. This topic shows how to enable attribute routing and describes the various options for attribute routing. End-to-end �������, � ������� ������������ ������������� � ������� ���������, ��. � ������� �������� REST API � ������� ������������� � ������� ��������� � ���-API 2. For an end-to-end tutorial that uses attribute routing, see Create a REST API with Attribute Routing in Web API 2.
��������������� ���������� Prerequisites
Visual Studio 2020 Community, Professional ��� Enterprise edition Visual Studio 2020 Community, Professional, or Enterprise edition
����� ���� ����� ����������� ��������� ������� NuGet ��� ��������� ����������� �������. Alternatively, use NuGet Package Manager to install the necessary packages. �� �������� ���� � Visual Studio, �������� ����� ��������� ������� NuGet, � ����� �������� ������� ���������� �������. From the Tools menu in Visual Studio, select NuGet Package Manager, then select Package Manager Console. ������� ��������� ������� � ���� ������� ���������� �������: Enter the following command in the Package Manager Console window:
������ ������������� ���������? Why Attribute Routing?
������ ������ ���-API ������������ ����������� �������������. The first release of Web API used convention-based routing. � ���� ���� ������������� ���������� ���� ��� �������������� ������� ���������, ������� �� ���� �������� ����������������� ������. In that type of routing, you define one or more route templates, which are basically parameterized strings. ����� ��������� �������� ������, �� ������������� URI � �������� ��������. When the framework receives a request, it matches the URI against the route template. (�������������� �������� � ������������� �� ������ ����������, ��. � ������� ������������� � ASP.NET Web API. (For more information about convention-based routing, see Routing in ASP.NET Web API.
����� �� ����������� ������������� �� ������ ���������� �������� ���������� ������� � ����� �����, ��� ������������� ���������� ������� ������������� �� ���� ������������. One advantage of convention-based routing is that templates are defined in a single place, and the routing rules are applied consistently across all controllers. � ��������� ������������� �� ������ ���������� �� ���������� ��� ��������� ������������ �������� URI, ������� �������� ������ � API-����������� RESTful. Unfortunately, convention-based routing makes it hard to support certain URI patterns that are common in RESTful APIs. �������� ������� ����� �������� �������� �������. ������� ��������� ������, �������� ����� ������, ����� � ������� � �. �. For example, resources often contain child resources: Customers have orders, movies have actors, books have authors, and so forth. �������, ����� ������� URI, ������� �������� ��������� �����: It’s natural to create URIs that reflect these relations:
����� ��� URI ������ ������� � ������� ������������� �� ������ ����������. This type of URI is difficult to create using convention-based routing. �������� �� ��, ��� ��� ����� �������, ���������� �� �������������� ����� � ��� ������, ���� � ��� ����� ������������ ��� ����� ��������. Although it can be done, the results don’t scale well if you have many controllers or resource types.
� ������� ������������� � ������� ���������, ��� ������ ���������� ������� ��� ������� �������������� ���� �������. With attribute routing, it’s trivial to define a route for this URI. ����� ������ �������� ������� �������� �����������: You simply add an attribute to the controller action:
���� ��������� ��������� �������, ������� �������� ������������� �����. Here are some other patterns that attribute routing makes easy.
���������� �������� API API versioning
� ���� ������� �/ api/v1/products� ����� ���������������� � ������ �����������, ��� �/ api/v2/products�. In this example, «/api/v1/products» would be routed to a different controller than «/api/v2/products».
������������� ��������� URI-������ Overloaded URI segments
� ���� ������� �1� � ��� ����� ������, �� ���������, �������� ����������� ���������. In this example, «1» is an order number, but «pending» maps to a collection.
����������� ������ ���������� Multiple parameter types
� ���� ������� �1� � ��� ����� ������, �� ���� �2013/06/16″. In this example, «1» is an order number, but «2013/06/16» specifies a date.
��������� ������������� � ������� ��������� Enabling Attribute Routing
����� �������� ������������� ���������, �������� MapHttpAttributeRoutes �� ����� ���������. To enable attribute routing, call MapHttpAttributeRoutes during configuration. ���� ����� ���������� ��������� � System.Web.Http.HttpConfigurationExtensions ������. This extension method is defined in the System.Web.Http.HttpConfigurationExtensions class.
������������� � ������� ��������� ����� �������� � ����������� �������������. Attribute routing can be combined with convention-based routing. ����� ���������� �������� �� ������ ����������, �������� MapHttpRoute �����. To define convention-based routes, call the MapHttpRoute method.
�������������� �������� � ��������� ���-API, ��. � ������� ��������� ASP.NET Web API 2. For more information about configuring Web API, see Configuring ASP.NET Web API 2.
����������. �������� � ���-API 1 Note: Migrating From Web API 1
������ ��� ���-API 2 ������� �������� ���-API ��������� ��� ��������� �������: Prior to Web API 2, the Web API project templates generated code like this:
���� ������� ������������� � ������� ���������, ���� ��� ������� ����������. If attribute routing is enabled, this code will throw an exception. ���� �� ���������� ������������ ������ ���-API ��� ������������� ������������� � ������� ���������, �� �������� �������� ���� ��� ������������ ���������: If you upgrade an existing Web API project to use attribute routing, make sure to update this configuration code to the following:
���������� ��������� �������� Adding Route Attributes
��� ������ ��������, ������������ � ������� ��������: Here is an example of a route defined using an attribute:
������ «�������� /
- http://localhost/customers/1/orders
- http://localhost/customers/bob/orders
- http://localhost/customers/1234-5678/orders
�� ������ ���������� ������������ � ������� �����������, ��������� ����� � ���� �������. You can restrict the matching by using constraints, described later in this topic.
�������� ��������, ��� «
������ URI ����� ����� ��������� ����������. A URI template can have several parameters:
������ �����������, � ������� ��� �������� �������� ����������� ������������� �� ������ ����������. Any controller methods that do not have a route attribute use convention-based routing. ����� �������, �� ������ �������� ��� ���� ������������� � ��� �� �������. That way, you can combine both types of routing in the same project.
������ HTTP HTTP Methods
���-API ����� �������� �������� �� ������ ������ HTTP ������� (GET, POST, � �.�.). Web API also selects actions based on the HTTP method of the request (GET, POST, etc). �� ��������� ���-API ���� ���������� ��� ����� ��������, � �������� ��� ������ �����������. By default, Web API looks for a case-insensitive match with the start of the controller method name. ��������, ����� ����������� � ������ PutCustomers ������������� ������ HTTP PUT. For example, a controller method named PutCustomers matches an HTTP PUT request.
�� ������ �������������� ��� ����������, �������� ����� � ����� ��������� ��������: You can override this convention by decorating the method with any the following attributes:
- [HttpDelete][HttpDelete]
- [HttpGet][HttpGet]
- [HttpHead][HttpHead]
- [HttpOptions][HttpOptions]
- [HttpPatch][HttpPatch]
- [HttpPost][HttpPost]
- [HttpPut][HttpPut]
��������� ������ ������������ ����� CreateBook �� ������� HTTP POST. The following example maps the CreateBook method to HTTP POST requests.
��� ���� ��������� ������� HTTP, ������� �������������� ���������, ����������� AcceptVerbs �������, ������� ��������� ������ ������� HTTP. For all other HTTP methods, including non-standard methods, use the AcceptVerbs attribute, which takes a list of HTTP methods.
��������� ��������� Route Prefixes
����� �������� � �����������, ������������ � ���������� ���������. Often, the routes in a controller all start with the same prefix. ������: For example:
����� ������ ����� ������� ��� ����� ����������� � ������� [RoutePrefix] �������: You can set a common prefix for an entire controller by using the [RoutePrefix] attribute:
) �� ������� method, ����� �������������� ������� ��������: Use a tilde (
) on the method attribute to override the route prefix:
������� �������� ����� �������� ���������: The route prefix can include parameters:
����������� �������� Route Constraints
����������� �������� ��������� ���������� ����������� ������������� ���������� � ������� ��������. Route constraints let you restrict how the parameters in the route template are matched. ����� ��������� «<��������: �����������>«. The general syntax is «
����� ������ ������� ���������� ������ ���� «�������������» ������� URI ������ ���� ����� ������. Here, the first route will only be selected if the «id» segment of the URI is an integer. � ��������� ������ ����� ������ ������ �������. Otherwise, the second route will be chosen.
� ��������� ������� ����������� �����������, ������� ��������������. The following table lists the constraints that are supported.
����������� Constraint | �������� Description | ������ Example | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
�����-������ alpha | ���������� ��������� ��� �������� ����� ���������� �������� (a-z, A-Z) Matches uppercase or lowercase Latin alphabet characters (a-z, A-Z) | ||||||||||||||||||||||
bool bool | ������������ ���������� ��������. Matches a Boolean value. | ||||||||||||||||||||||
datetime datetime | ���������� DateTime ��������. Matches a DateTime value. | ||||||||||||||||||||||
decimal decimal | ������������� �������� ����������� �����. Matches a decimal value. | ||||||||||||||||||||||
double double | ��������� �� ��������� � ��������� ������� 64-���������. Matches a 64-bit floating-point value. | ||||||||||||||||||||||
float float | ��������� � 32-��������� �������� � ��������� �������. Matches a 32-bit floating-point value. | ||||||||||||||||||||||
guid guid | ��������� �� ��������� GUID. Matches a GUID value. | ||||||||||||||||||||||
int int | ��������� �� ��������� 32-��������� ����� �����. Matches a 32-bit integer value. | ||||||||||||||||||||||
����� length | ������������� ������ � ��������� ��������� ����� ��� � ��������� ��������� ����. Matches a string with the specified length or within a specified range of lengths. | long long |
��������� �� ��������� 64-��������� ����� �����. Matches a 64-bit integer value. |
| max max |
������������� ����� ������������ ��������. Matches an integer with a maximum value. |
| MaxLength maxlength |
������������� ������ � ������������ ������. Matches a string with a maximum length. |
| min min |
������������� ����� ����� � ����������� ���������. Matches an integer with a minimum value. |
| minLength minlength |
������������� ������ ����������� �����. Matches a string with a minimum length. |
| range range |
������������� ����� ������ � ��������� ��������. Matches an integer within a range of values. |
| regex regex |
������������� ����������� ���������. Matches a regular expression. |
|
�������� �������� �� �� ��� ��������� �����������, ����� ��� «min», ��������� ��������� � ������� ������. Notice that some of the constraints, such as «min», take arguments in parentheses. ����� ��������� ��������� ����������� ��� ���������, ����������� ����������. You can apply multiple constraints to a parameter, separated by a colon.
���������������� ����������� ��������� Custom Route Constraints
����������� ���������������� ��������� ����� ������� ����� ���������� IHttpRouteConstraint ���������. You can create custom route constraints by implementing the IHttpRouteConstraint interface. �������� ��������� ����������� ������������ �������� ��������� ������������� ��������. For example, the following constraint restricts a parameter to a non-zero integer value.
���� ��������, ��� ���������������� �����������: The following code shows how to register the constraint:
������ ����� ��������� ����������� � ���� ��������: Now you can apply the constraint in your routes:
����� ����� �������� ���� DefaultInlineConstraintResolver ������ ����� ���������� IInlineConstraintResolver ���������. You can also replace the entire DefaultInlineConstraintResolver class by implementing the IInlineConstraintResolver interface. ��� ������� ��� ���������� �����������, ���� ���� ���������� IInlineConstraintResolver ���������� ��������� ��. Doing so will replace all of the built-in constraints, unless your implementation of IInlineConstraintResolver specifically adds them.
�������������� URI ��������� � �������� �� ��������� Optional URI Parameters and Default Values
����� ������� �������������� ��������� URI, ������� �������������� ������ ��� ��������� ��������. You can make a URI parameter optional by adding a question mark to the route parameter. ���� �������� �������� �������� ��������������, ���������� ���������� �������� �� ��������� ��� ��������� ������. If a route parameter is optional, you must define a default value for the method parameter.
� ���� ������� /api/books/locale/1033 � /api/books/locale ���������� ��� �� ������. In this example, /api/books/locale/1033 and /api/books/locale return the same resource.
����� ���� ����� ������� �������� �� ��������� � ������� ��������, ��������� �������: Alternatively, you can specify a default value inside the route template, as follows:
��� ����� ��� ��, ��� � ���������� �������, �� ���� �������������� �������� ���������, ����� ����������� �������� �� ���������. This is almost the same as the previous example, but there is a slight difference of behavior when the default value is applied.
(� ����������� ������� ��� ���������� ���������������� ����������� ������ � ���������, ��� ����� ����� �������������.) (In most cases, unless you have custom model binders in your pipeline, the two forms will be equivalent.)
����� ��������� Route Names
� ���-API ������ ������� ����� ���. In Web API, every route has a name. ����� ��������� ����� ������������ ��� �������� ������, ����� �������, ����� �������� ������ � HTTP-������. Route names are useful for generating links, so that you can include a link in an HTTP response.
����� ������� ��� ��������, ������� ��� ��������. To specify the route name, set the Name property on the attribute. ��������� ������ ����������, ��� ������ ��� ��������, � ����� ��� ������������ ��� ��������, ��� �������� ������. The following example shows how to set the route name, and also how to use the route name when generating a link.
������� �������� Route Order
����� ��������� �������� ������������� URI � ���������, ��� ��������� �������� � ������������ �������. When the framework tries to match a URI with a route, it evaluates the routes in a particular order. ����� ������� �������, ������� ������� �������� ��������. To specify the order, set the Order property on the route attribute. ����� ������ �������� ����������� �������. Lower values are evaluated first. �������� ������� �� ��������� ����� ����. The default order value is zero.
���, ��� ������������ ����� �������: Here is how the total ordering is determined:
��������� ������� �������� �������� ��������. Compare the Order property of the route attribute.
���������� ������ ������� URI � ������� ��������. Look at each URI segment in the route template. ��� ������� �������� ������� ��������� �������: For each segment, order as follows:
- ������� ��������. Literal segments.
- ��������� �������� � �������������. Route parameters with constraints.
- ��������� �������� ��� �����������. Route parameters without constraints.
- �������� � ��������������� ������� �������� � �������������. Wildcard parameter segments with constraints.
- �������� � ��������������� ������� �������� ��� �����������. Wildcard parameter segments without constraints.
� ������ ��������� ������������ �������� �������� ��������������� �� ��������� ����� �� ����������� ������ ��� ����� �������� (OrdinalIgnoreCase) ������� ��������. In the case of a tie, routes are ordered by a case-insensitive ordinal string comparison (OrdinalIgnoreCase) of the route template.
������. Here is an example. �����������, �� ����������� ���������� �����������: Suppose you define the following controller:
��� �������� ����������� ��������� �������. These routes are ordered as follows.
- ������ � �������� orders/details
- ������ /
orders/ - ������ /
orders/ - ������ / <*����>orders/
- ������ / �������� orders/pending
�������� ��������, ��� ������������ �������� ��������� �������� � ���������� ����� �
����������� �� ���������� HTTP API
��������
������ ����������� �������� ������������ �� �������������� HTTP API, ������� ���� ���������� �� ������ API �������� ��������� Heroku, ����� ����, ��� ����� �������� ���������� � ����� ����������� � ���������� API � Heroku.
������ ��������� ������ ��� ���������� API �������� ���������� ������������������ � ������������ �� ���������� ������-������. �� ���� ���������, �� ����������� ����� ������, �� ������ ��������������� ������� ���������� API.
��� ��������� ������ ������ ���������������, ��� �� ������� � ��������� ���������� HTTP � JSON.
������
������� ���������� ���������������
��� �������������� ���������� ��������� �������� �������, �������� ��������������� ����� ���������� ������� ����� �������-�����. ��� ���� �������� ����������� ������� �������� ���������������� �� ������� ��� ����� ������� �����. ������� � ������ ����������� ��� ��������� ������� � ������������� ������� ��� ������ ��������. ��� ����������� ��������, ������� ���������� ��������, ����������� ���� � ���� ������ ��� �������� �����������, � ��������� � ��� �������� ����������. ����� ���������� ��� ��������� � ���� �������, ��, ��� ���������� ��������, ����� ������� �������� ����� ������. ����� ���������� �������� ����� �������� ����� ���������� � ����������.
�������� ������������� ���������� ����������
��� ��������� ������ ��� ������ API ����������� ������ ���������� ���������� � TLS.
����� �������� ���� �� ��������� ��� �������, �� ������������ TLS, � ������ ������� �� http ��� �� 80-�� ����, �� ��������� ������������� ������ �������. � �������, ����� ��� ����������, ��������� ����� 403 Forbidden .
14 ������ � 10:00, �����-���������, ��c������
��������������� �� ��������������, ��������� ��� ��������� ������������ ��������� �������, �� ������������ ��� ���� ������� ������ ����������. �������, ������� ���������� �� ���������, ��������� ����� ������� ������ ������� � ������������� TLS � ���� ������ ����������, ��������� ������ ������ ����������� ������������� ��� ������ ������.
�������� ������� ������ � ��������� Accept
������� ���������� ������ � �������� ����� ���� ����� ���� ����� �� ����� ������� �������� �������������� � ������������� API. ������� ����� ������� ������ ���� ������.
��� ����, ����� ������ �� ����������� ������������ API, ����� ����� ��������� ������� ��� ������ � ������ �������. ��� ���� ����� �������� �������� ������ �� ���������, ��������� ��� ����������� ��������� ���������, � ��� ������ ����� ����� �������� � �������.
����� ����� � �������� ������ � ��������� ������ � ������� �����������, ��������� ��������� Accept � ���������������� ����� �����������:
����������� ��������� ETags ��� �����������
��������� ��������� ETags �� ��� �������, ��������� ��� ���� ������ ������������� �������. ��� �������� ������������� ���������� ������� � ������������� �������� ������� ��� ������ ������������� ��������� If-None-Match , ������� ������� ����������, ����� ��������� ��� ��� ���.
����������� Request-ID ��� ������������
��������� ��������� Request-Id , ���������� � ���� UUID ��������, � ������ ����� �������. ����������� ��� �������� �� �������, ������� ��� ������ �������, �� ��������� ����������� ���������� � ��������������� ��������, ��������� � ���������.
���������� ������� ������ ������� �� ��������� ��������� ��� ������ ��������� Range
������� ������ ���������� ��������� �� ����� ������, ��������� ��������� Range . ��� ��������� ����� ��������� ���������� � ���������� ��������/�������, ����� ��������� � ������������ ������� ���������� ������������� ��������� Range � API ��������� Heroku .
�������
����������� ��������������� ���� ���������
����������� �������������� ��� ��������� HTTP � ������ ������. �������� ������ ������ ��������� ����� ���� ���������:
- 200 � GET ������ ���������� �������, ���������� DELETE ��� PATCH ������ ���������� ������� ��� ���������� PUT ������ ������� ������������ ������.
- 201 � ���������� POST ������ ����������, ���������� PUT ������ ������ ����� ������.
- 202 � ������ POST , PUT , DELETE ��� PATCH ������, ������� ����� ��������� ����������.
- 206 � GET ������ ���������� �������, �� ����� ��������� ��������� ����� (��. ������ ��� ��������� Range ).
�������� �������� �� ������������� ����� ��������� ������ ����������� � ��������������:
- 401 Unauthorized � ������ ���������� � �������, ��������� ������������ �� ������ ��������������.
- 403 Forbidden � ������ ���������� � �������, ��� ��� ������������ �� ������������� ��� ��������� ������� � ������������� �������.
����������� ��������������� ���� ������ ��� �������������� �������������� ���������� �� �� ��������:
- 422 Unprocessable Entity � ��� ������ ��� ���������, �� �������� �������� ���������.
- 429 Too Many Requests � �������� ����� ��������, ���������� �����.
- 500 Internal Server Error � �������� �� ������� �������, ��������� ��������� ����� �/��� �������� � ��������.
��� ��������� ����� ��������� ���������� � ����� ��������� HTTP ������� ������������.
�� �����������, �������������� ������ ������ ��������
����������� ������������� ������ API ������ ������������� ������� (�� ���� ������ �� ����� ����������) �� ���� �������, ��� ��� ��������. ������ �������������� ������ ������ ������� � ������� �� ������� � ������ ��������� 200 � 201 , ������� PUT , PATCH � DELETE �������.
������ �� ������� � ����� ��������� 202 �� ������ ��������� ��� ���� �������
��� API ������ ��������� ��������������� JSON � ���� �������
��� API ������ ��������������� ����������� �������� ���������������� JSON � ���� PUT / PATCH / POST �������� ������, ���� � ���������� � ������������ ������ �����. ����� ������� ��������� ��������� � JSON-�������:
������ ��������������� ��� ��������������� ���� � �������
�������� ��������
����������� ������������� ����� �������� �������, �� ����������� ��� �������, ����� ������������� ������ � ������� ������ ���� � ��������, � ����������� ������, � ������������ ������ ������ ���� �������. ����� ������ �������� ��������� ������������ ��� ������� � ����������� �������.
��������
���������� ������������� ����� �������� url, ������� �� ������� �������������� �������� ��� ��������� ��������. � �������, ����� ��� ����������, ���������� � ����� ���� ��������� �action� ��� ����, ����� ����� ���������� ��� ��������:
����������� �������� ����������� ���� � ��������� � ������ ��������
��� �������� ����������� ���� � ������� ����������� ������ ������� � ���������� �� ��� ������ ������.
�������� ��������� ����� ������ � ������ ��������, � � �������� ����������� ����� ������������ ������ ������������� � ����� ������� �������� ����� ����� ������ ��� ������ � Javascript:
��� API ������ ������������ ������ � ������� �� ������ �� ��� id
� ��������� ������� ��� �������� ������������� �������� ������ � ������� �� ��� ��������������. ��������, ������������ ������� ��� ������� � ����������� ���������� Heroku ������������ �������� ����������, � �� ��� UUID. � ����� ������� ����� ������������ ������ ��� �� �����, ��� � �� ��������������:
������� � �������� ���������� �������� � ���� ��� ������� � �������
� ������� ������, � ������� ������������ ������������ ��������� ����� ����������, ���� ������� � �������� ����� ����� ������� ������� �����������:
�� ������ ���������� ������� �����������, ���� ������ ��������� ������� � �������� ����������. ����������� ����� ������������ ��� ����������� ������� � ���������� ��������:
������
�������������� UUID ������������� ��������
� ������� ������� �� ��������� ������ ���� ������� id . � �������� �������� �������������� ������� ���������� ������ ������������ UUID. �� ����������� ��������������, ������� �� ����� ����������� � �������� ������ �������, �������� ���������������� ��������������.
UUID ������� �������� � ������� 8-4-4-4-12:
�������������� ���������� � ���� �������� � ��������� �������
�� ��������� ������ ������ ������� ���������� � ���� ��� �������� created_at � ���������� updated_at .
��������� �������� ������ ���� ������������� �������� ISO8601
���������� � ����������� ��������� ������ ������ � UTC, � �������� � ������� ISO8601:
��������� � �������� ���������� ������ ���� �������� �� ��������� ������
������� ��������� ������ ���� ������������� ��� ��������� ������:
� �� ��� ���� �������:
����� ������ ��������� �������� ������ ���������� � ��������� ������� ��� ������������� ������ ��������� ������:
���������� ����������������� ������ � ������ ������������� ������
��������� ����������������, ����������������� ���� ������ � ������ ������������� ������. ����� ��� ���� ������ ��������� ������������� ��������� �� ������ �, �����������, url , ������� ��������� ������� ��� ����� �������� �������������� ���������� � �������� � �������� �� �������.
����������� ����������� �� ���������� ��������
����������� �� ���������� �������� �������� ��� ����������� ����������������� ������� � ����������� ������������� ������������ ������ ��������. ��� ������� ����������� �� ���������� �������� ����� ������������ �������� �������� �����. ����������� ���������� ���������� �������� ��� ������� ������� � ��������� ������ RateLimit-Remaining .
JSON �� ���� ������� ������ ���� �������������
������ ������ ����������� ������ ������ � ������ Javascript ������� ��� ��������������� ������������� ������������� JSON. ������� ����� �������������� JSON ������:
�� ������ ����������� �������� ����������� �������� ����� ����������� �����, �������� �������������� �������� (��������, ?pretty=true ) ��� ������� �������� ��� ��������� Accept ( Accept: application/vnd.heroku+json; version=3; indent=4; ).
���������
�������������� ������� ��� ��������� JSON-�����
��� ������� �������� ������ API �������������� JSON-�����. ��� ���������� ������ ����������� prmd, ����� �������������� � ���, ��� ��� �������� ��������� ��� ������ ������� prmd verify .
�������������� ������������� ������������
��� ����, ����� ������������ ����������� � ��������� ������ ������ API, ������������ �� ������� ������������. ���� �� ������� JSON-�����, ��������� prmd , ��� ������� ����, �� ������ ����� ������������� Markdown ������������ ��� ���� �������� url, ��������� ������� prmd doc .
�������� � �������� �������� url, ������������ ����� API, ������� ���� ��������� ����������:
- ������� �������������� � ��������� � ������������� ����������������� ������;
- ������������ API � ��� ������, � ����� ���������� � ���, ��� ������� ������ ������ API;
- ����� ��������� �������� � �������;
- ������ ������ ������;
- ������� ������������� API � ��������� �� ������ ������;
�������������� ������� ��������, ������� ����� ��������������
�������������� ������� ��������, ������� ������������ ����� ��������������. ��� ������������ ���� �������� ������������ ������ ��������� ������� ��������:
���� �� ����������� prmd ��� �������� ������������, �� ����� ������� ����� ������������� ������������� ��� ������� ��������� url.
������� ������������ ������ API
�� ������ ������� ������� ������������ ������ API ��� ��������� �������� url ��� ������ ��������� ������ prototype / development / production .
��� ��������� �������������� ����������, �� ������ ������� �������� �������� ������������� Heroku API.
��� ������ �� �������� ��� API ������� � ������ � ����������, �� ����� ��������� �����������, ������� �������� �������� ������������� ������ ���� ������. ��� �������� ����� ��������� �������� ����� ����� API � ����� �������� ������.
������� � �������������� RESTful API
�����: �������� ��������, Solutions Architect.
� ���� ������ � �������� ������ �������������� RESTful API � �� ���������� �������� ������, ��� ������ ���� �� ������� ������� �������. ����� �� ���������, ��� ����� API � ����� �� �����, ��������� �� ������� REST � �������, �� ��� ��� ����� �������������; �������� �������� ���-�������, ������� ������� � �� ������� �� ���� ����������. ����� ������, ��� ���������� ������� ������������, ���������� �� ��� ������� ������, � ���������, ����� ���������� ������� ��������� ������ ��� RESTful API.
����� 1. ������
����, ��� �� ��� �����, API � application programming interface (��������� ���������������� ����������), ����� ������ � ����������, � ������� ������� ���� ���������� ��� ��������� ��������������� � �������
������ ������� API � ��� �����?
- �������� ������������� � ���������. ������� API ������ ������������ � ������������.
- ������� ��������� � ����� �������������. ���� ���� �������� ��� API, � ��� �������� ����� ������� � ������������.
- ���� ������������ ������ �������. ��� ������ ������������� API, ��� ���� ������������ ������ �������.
- ����� �������� �����������. ��� ����� ��������� API, ��� ����� �������� �����������.
- ������� ����������� � ��������. API � ��� ��� �� UI �������������; ��� ��, �� ��� ������������ �������� �������� � ������ ������� ��� ������� � ���������. ���� API ������, �� ��� ����������� ������� �� ������ ������������� ��������� ������������ ����� �������, ���������� ���-�� ���������.
������ ���������, ����� ������ ���� API.
���� API �� ������� ����������:
- Web service APIs
- XML-RPC and JSON-RPC
- SOAP
- REST
- WebSockets APIs
- Library-based APIs
- Java Script
- Class-based APIs
- C# API
- Java
���� API �� ���������� ����������:
- OS function and routines
- Access to file system
- Access to user interface
- Object remoting APIs
- CORBA
- .Net remoting
- Hardware APIs
- Video acceleration (OpenCL�)
- Hard disk drives
- PCI bus
- �
��� �� �����, � Web API ��������� XML-RPC � JSON-RPC, SOAP � REST.
RPC (remote procedure call � ���������� ����� ��������) � ������� ����� ������, ������������ �������, ������� � ����������� ���������, ������� ��������� ������� ����� � ������ ����������. XML-RPC � ��������, ����������� � 1998 �. ������ ����� ��������� XML. ���������� �� ������������� Microsoft, �� ������ Microsoft ��������� ������������� �� SOAP, ������� � .Net Framework �� �� ������ ������� ��� ��������� ����� ���������. �������� �� ���, XML-RPC ���������� ���� �� ��� ��� � ��������� ������ (�������� � PHP) � ������, �������� ������ ������������� ���������.
SOAP ����� �������� � 1998 �. ���������� Microsoft. �� ��� ����������� ��� ��������� � ���� ��. ������ �������, ��� ��� ����� �� ����� Microsoft: ���� �������� ���������� ������� ��-�� ��������� � �������������� ���������. � �� �� �����, ���� � ��, ��� ������ SOAP ��������� ��������. �������� ��������� ����������� � ��������� ��������� ����� � ����� ������������, ���� � 2003 �. W3C �� ��������� � �������� ������������ SOAP 1.2, ������� � ������ � ���������. ��������� � SOAP ���������� ������������: WS-Addressing, WS-Enumeration, WS-Eventing, WS-Transfer, WS-Trust, WS-Federation, Web Single Sign-On.
�����, ��� �����������, ��� �� �������� ������������� ������� ������ � REST. ������������ REST ���������������� ��� representational state transfer � ��������� ��������� �������������� ���, ����� �������, ������������� ������ � ������� ��� ������� �������. ������ �REST� ��� ������ ���� ��������� � 2000 �. �������� ���� REST � ���, ��� ������ ��������� � ������� ��������� ���������� ���������� � ����� ���������. �� ����, REST � �� �������� � �� ��������, � ������, ������������� ����� �������������� API.
������ �������� REST?
- ������-��������� ����������� � ��� ����� REST ��������.
- ����� ������ � ������.
- ����� ������ ����� ID, �� �������� ����� �������� ������.
- ������� ����� ���� ������� ����� ����� � ��� ����� � ������� ������ ���������� ���� ID, ����, ��� ���� �������������, ������. �� � ���� �� ����� �� ����, ����� ��� ���� ��������� ������, ����� ����� ���� ����� ������������ ������.
- ������������ ����������� ������ HTTP (GET, POST, PUT, DELETE) � �. �. ��� ��� �������� � ������� ���������, �� �� ����� ������������ ��� ����, ����� ��������� ������ �������������� � ����� ��������.
- ������ �� ������ ��������� � ��� ������, ������ �� �������� ���� ����� �� �������, �� ��������� ��� ������ � ������. ���� � ��� ���� �����-���� �������������� ������, �����-�� ����� �� ��������, ������� ��������� ��� ������, ��� ������������� ������������ ��������������� ��������� ���� �������� ����� ����� ������, ������� � ��� ����. ��� ������ �������� ��������������� � ��� ���������� ��� ������ ���� ��� ��������� ��������.
- �� ����� �����!
- �� �������������� ������������ ���������, ������� � ���� ��� ����� ����� � ����������� �� ������ �����������.
- REST ������������ �� HTTP => �������� ��� ������:
- �����������.
- ���������������.
- ������� ��������� ��������.
- ����������� ���� ������.
- ����� ������� ������������������ (���� IoT-���������� ��� ����� �������� �� HTTP).
������ ������� (����������� �� ����������)
����� � ����������� ���� ���� ������ �������, �� ��������� � ���������� �����������? ��� ������� ������� ������������ �����������:
- SSL ������� � ����� ������ � ����� �������, �. �. ��� SSL ����������� � �������������� ������������.
- ������������ � ������������ ������� � � ������� ��� ������.
- ������ POST � PUT ������ ���������� ������� ������, ������� ��� �������� ��� �������, � ��� �������� ��������� ����� ��������� � ������� �����.
- ��������� ����������, ���������� � ������������� ������ � ����� ����������, ����� ��� ���� ���������� � �������� ��� �������.
- ��������� MediaType. MediaType � ������ ������� �������, � ����� ������� �� ������ �������� ����������. ���� �� �������� �����-���� ����������� ���������� web API � ������� ���� �� ��������, API ������ ��� XML, � ���� ������� ����� �����-������ Postman, �� ������ JSON.
- Prettyprint & gzip. �� ������������� ������� � �� ������� ������� ��� JSON (���� ������, ������� ������ �� �������). ��������� ������� �� prettyprint �������� ���������, ��� �����, ���� ����������, ������� �������� ���� �� ��������� � ������ ������� ���������. ���� �� ������� ���� � ������ ��������� ��� � ���� ������, ���������� � ��������. ��� �������� gzip, �� ���� ������� � ����. �. �. ����� ������� ������������ � prettyprint, � gzip.
- ����������� ������ ����������� �������� ����������� (ETag) � Last-Modified (���� ���������� ���������) � ���� ���� ���������� ������� ����������, ����� ������ �����, ��� ���������� �� ������� ����������. ����������� ���-�� ���� ��� �� ����� ������.
- ������ ����������� ����������� ���� ������ HTTP. ����� ��� ������� �������� ����-������ ���������, ������ �� ������, ��� ������ 419 � ����� ������� ������� ����� ���������� ������ ���, ��� �� ������-�� ���������. ��� �������� � ��������� � �� ��� ������ ��� ������� �� ������!
�������� HTTP-�������
������� �� ����� �������� ������ ��� GET, POST, PUT, DELETE.
���� �������� ������� �� ���������, �������������� � �������, OPTIONS � ��������� �������� ������������, HEAD � ��������� ���������� ��� ���� ���������, PATCH � ��������� ��������� �����������.
��� �� ������, ��� ������, ����� POST, �������������� � �������, ������������. ��������������� � ����������� ��������� ���� � �� �� ��������� � ������� ��������� ���, ��� ���� ����� ������ ��� ����� ����������. ������� �������, �� �����, �� ����� ������� � ������� ��� �� ��������� ��� ��������. ��������, �� ��������� �������� �� ��������� ������� (PUT), � ��� ������ ������. �� �� ������, ��� �� ������� � � ����� ������, �� �� ������, ��������� ������ ��� ���. ��, ��������� ���������������, �� �������������� ������ ��������� ���� �������� ��� ���, �. �. ������� ����� ���� �������� �� ����������� ����� ������.
�Safe� �� ������, ��� ��������� � ������� �� �������� ����������. ���, GET ����� ���� ������ ����� ���, �� �� �� ������� �������� �����������. ���� �� �� ������� ����������, � ���� ����, ��� GET ����� ���� �����������, ��� �������� �� �������� � ������������, ���������� �����-������ ������ ���������.
����� 2. ��������
�������� ����������
������, ����� �� ������, ��� �������� REST, ����� ���������� � ��������� RESTful API � �������, ����������� ��������� REST. ������ � ������ ����������.
������ ������� � WCF Services. ���, ��� ������� � ���� �����������, ������ ������������ � ��� ������ �� ����� � � ��� ���� ��������� ���������� � ���� ������:
� webHttpBinding only (� ����� ����� ���������. ).
� �������������� ������ HTTP Get & POST (� ���).
+ ������ ������� XML, JSON, ATOM.
������ ������� � Web API. � ���� ������ ����� ��������:
+ ����� �������.
+ �������� �������� ���.
+ ��� ����������� HTTP.
+ ��� ����������� MVC.
+ ������.
+ ���� ������������ ���� ��������.
�����������, �� �������� Web API. ������ ������� ���������� ������� ��� Web API.
�������� ������� ��� Web API
��� ���� ���������� ���������:
- ASP.NET MVC (������ ������).
- Azure (�������� ���������).
- OWIN � Open Web Interface for .NET (������ ���������� �� Microsoft).
- IIS
- Self-hosted
OWI
OWIN � �� ��������� � �� ����������, � ������������, ������� ��������� ������� ����������� ���-���������� � ����������� �������. ��� ��������� ��������� ���������� �� ����� ���������, �������������� OWIN, ��� ���������. �� ����� ����, ������������ ����� ������ � ��� ������ ��������� �� ���������� � �� ��������. ������� ��������� ���������� � ������������.
OWIN �������� � ����� ������� �����������:
�� ����� �� �����, ��� ���� ����, �� ������� ���� ������, ������� ������������ ����� ������� ���������, ��������� �� ������� ��������� � ��������. ��� ������, ������� ������������ � ����� �������, ��������������� ������ ���. ������, �������������� ���� ��������, ����������� � ������������ ���������, ����� ������������ ��� ��� ��������� � ���������������� �������������� ��������������� �������. ����������, ���, ���� �� ������ ������, ������� �������� � OWIN, ������ ��������, ��� ��������� ����, ���������� ��� ����� ����������� � ������������ �� �� ����� �� ������ ��.
Katana � ���������� OWIN �� Microsoft. ��� ��������� ��������� OWIN-������ � IIS. ��� ��� ��� ��������, ����� ������:
�� ����������, ����� ����� �������� � ��� Startup. ��� ������� dll, ������� ����������� IIS. ���������� ������������. ����� ���� ����������, ����� ��� ����������.
����������� ���������
������ ������������ ��������� � ���������, ��� ��� ������ ��������� � ����� �������� ���������������. ��� ������� � REST � ���������������, ��, ��� ����� �������� � ���������.
��� ������ ������� ������� ������ � ����������� �������� ������� �� ��������. ��� ������� ���������� �������� REST:
- �������� (�����������) �������� API:
- GET /stations � �������� ��� �������.
- GET /stations/123 � �������� ���������� �� ������� � >
- ��������� (�� ��������) ��������:
- GET /stations/555/departures � ������, �������� � ������� 555.
����� � ��� �������� ��� DDD, ������ �� ������ ������ ���.
����������
����, � ��� ���� �������, � ������ ��� ����� �������� ���������� ����������:
��� �������, ����������� �� ���������. ����� �� ��������� ��� ����������� � ������ ������ ������ (� ������ ������ � ��������� �������� ������).
OData (www.odata.org)
������ �����������, ��� � ��� ������ ������, ��� ����� �� ������� (������ ��� ������ ���� �� ����� �����). ��� ���� ������ ������ �����-���� ��������� �� ��������, �������, ������ �� �������. ������ ����� ���� ������� ������ � ������������ ������ ������ OData, ������� �������������� Web API.
IQueryable ��������� ��� ������������ ��������� �������, �� ����������� ���������� ���������� � ���������� ������� �� ���������� �������. ������������, ��� ����� �������, � ���������� OData-������ �� NuGet, ������� EnableQuery � ���������� ��������� iQueryable.
�������� ������� ����� ����������� ����� �� ����������� � ���, ��� ����� ��� �����������, ������� ���������� ����������. ����������� OData ������� �������� ����� (������������ � ����. ������� ������, ������� �� ����������� ����������) � ����� ���������� ��������� ������ ��������, ������� �� ������ �� ������. ����� ����������� ������ OData �� ����� ������ ����� ����� join, count � �. �.
��������� ��������
� ��� ��� ����� ������:
- $filter � ������, �� �����, ��������. ��� ������� ����� ���������� �� ����� OData � ��� ����� �������� � ��������� ����������� ���������� �������.
- $select � ����� ������ �����. ���� � ��� ������� ��������� � ��� ������� �������, �� ��� ���� ��� ����� ������������ �����-�� dropdown, � ������� ��� ������, ����� ID � �����, ������� �� ������ ����������, � ������� ��� �������, ������� �������� � ������� �������������� � ��������.
- $orderby � ����������.
- $top � $skip � ����������� �� ��������.
����� ����������, ����� ������ �� ���������� ����������. ��� ��� ����� ����������� JS-���������� ����� Breeze.
EnableQuery Attribute
�� ����� ���� OData � ����� �����, ������� ����� ����� ����� ���������� ���� � ����. ���� � ��� � ������� �������� �������, � ��� ����� ������ �� � ������� �� ������, ��� ����� ������, � ���� ����� �������� ����� ����� � ������ ����������.
������ ��� ����� ������� � �������� EnableQuery (��. ��� ����) ���� ����� ����� ����������, � ������� ������� ����� ������ ����� ����������: �� ������ ������ �����, ��� ����, �� ������ ������ join, �������������� �������� � �. �. ��� ���� ������ ������ ������ �� ����.
- AllowedArithmeticOperators
- AllowedFunctions
- AllowedLogicalOperators
- AllowedOrderByProperties
- AllowedQueryOptions
- EnableConstantParameterization
- EnsureStableOrdering
- HandleNullPropagation
- MaxAnyAllExpressionDepth
- MaxExpansionDepth
- MaxNodeCount
- MaxOrderByNodeCount
- MaxSkip
- MaxTop
- PageSize
��������� ����������
����, ��� ������� ���������� �������� REST:- GET /stations � �������� ��� �������
- GET /trains � ���������� ���� �������
- GET /stations/555/arrivals
- GET /stations/555/departures
��������, � ��� ���� ������ 555, � �� ����� �������� ��� ��� ����������� � ��������. ��������, ��� ����� ������ �������������� ��������, ������� ������� �� �������� �������. �� ��� ��� ������� � ������������? ���� �� ��� ��� ����� ������ �������-���������� � ���������� � ���� �����, �������, ��� � ����� �������, ��� � ���, ������� ���. �� ���� � ��� ����� ������� ��������� ��������� � ������� ����� ����� ��� ������, ��� ��� �������� � ���������������� ������.
� ��� ���� ������� ������� � � �������-��������� � ������������ ����� ������ ����������:
��������������, ��� ��������� �������� �������� � ��������� ����������. ������� �� � ���������� �������, ��� ��� ��� ����� ��������. � ����� ������ Web API, ��� ����� �������������� ������� ������������� � ���� ������� ��� �� �� �����, ��� ��� ��������, �������� �� ��, ��� � URL ��� �������� ��������.
������������, ��������� �������� � ����� � ��� �stations�, � �� ����� ��� �stations�. ���� �� � ����� ����� ���-�� ���������, � � ������ � ������ �� ���������, ������ �������� �� �����. ������ ��� ���� ������� ������� � ������������� �������� ��� ��������:
����� ��������� ���������� ����� ��������� ���:
�� ������ ������ ��� ��������� ������������ ���������� �������� � �� ������ ������ � ���������� ���� ����, � ����� �� �� ���������. ����� ����, ��� ����� ������� ������������ � ������������. ���� �� ������ �������� ���� � ����� ������ ���� ���������, � �� ������ ������ ��� �� ���� ��������� ����� ������ � ���������� ��� ������, ��� ������� ��� ������������� URL��, �� �� ����� ������ ������������ ��� ���������. ����� �� �� �������, ������ � ��� �������� �����. ��� ����� ������.
����, �� � ���� ��������, ��� ����� ��������� ���������� GET-��������. ��� ��������, ��� ������� ��������� GET. ��, ����� ����, ��� ����� �������� ��� ��� ��������.
- POST � ������� ����� ��������
- POST /Stations � JSON-�������� �������� �������. �������� ��������� ����� �������� � ���������.
- ���������� ��������� �������� (��-������, ����� �� ���� ������� ������� � �������, ��-������, �����, ���� ��� �����, ������� �� ������� ������� ���������, ������� ����������� � ���� ������� � ����� ��� �� �������).
- PUT � �������� ��������
- PUT /Stations/12 � �������� �������� � >
- DELETE
- DELETE /Stations/12 � ������� �������� � >
��� ������� CRUD:
- POST /Stations � ��������� ������.
- POST /Stations/1/Departures � ��������� ���������� �� ����������� � ������� 1.
- DELETE /Stations/1/Departures/14 � ������� ������ �� ����������� � ������� 1.
- GET /Stations/33/Departures/10/Tickets � ������ ��������� ������� ��� ����������� 10 � ������� 33.
����� ��������, ��� ���� � ����������� �����-�� ��������, ��, ��� ����� ����������� (�����, �����, ���� ����������� ������ � �. �.).
�����������
� ��� �������, ��� ������ �� ����:
- GET /Stations/?op=departure&train=11
����� query string ������������ �� ������ ��� �������� ������, �� � ��� ��������. - GET /Stations/DeleteAll
��� �������� ������ �� �����. ��� �� ������ GET �� ���� �����, � ��, �� ����, ������ ������� ��� �������� �� ��������� � � ����� �� ����� ���� ����� �������������� ��-�� �����������. - POST /GetUserActivity
�� ����� ���� ����� GET, ������� ������� ��� POST. POST ����� ��� ��-�� ���������� ������� � body, �� � body � GET ������ ������ �������� � GET ����� �������� ������ � query string. GET ���� �� ��������� �� ������������ body. - POST /Stations/Create
����� �������� ������� � ������� URL � ��� ���������.
����������� API
��������, � ��� ���� API, ������� �� ������ ���������� �����, � ���� �������� ������. ��� ������� �������� API � �������� �������? �� ����� ��� �� �������, �� ����� ����. � ���� ��� ������� �������������: ��, ��� �� ������� � API, ����� �� ������� � ����� ���������� �������� �������.
����� ���������� ������, ��� ������������� API, ���� ��� �� CRUD? ��� ����� �� ���������� ����� �������� ��� ������� �� ���������. �� ������ ����������, ������, �������� �������, GET, �������� ������� ���� �������. GET �� ��������� ������ � �� ��������� ������ ���� ������, ������� �� ���������� ��� �����-���� ���������� ��������.
�������� ������
�� ��������� � ����� �������� ������ � ���������. � ������� � ��� ���� ����� (Hotel), ���� ������������ (Reservation), ������� (Room) � ���������� (Device), � ��� �����������. � ����� ������� ��� ��������� ��������� ��������� ����������� ���� ���������.
�� ��� ��������: ���������� � ��������, ������� ����� ����� ������, � ���������, ��� �� �������� �� �����. �� ��������� ����� � ����������, �� ����� ����, ����� ������ � ������� DDD. � ������ �������, ����� �����������, ��� ������� �������� �������� � ��� ������� ���������, ������������� �� ��������������� �������.
Bounded context (BC)
Bounded context (������������� ��������) � ����������, ������ ��������, �� ��������� ���� �� ����� � ������� ���������� ����������� ������ (������). � ������� �� ����� ����� � ��������� ����� � ���������� �� ��� ������ BC � ��� �� ������� ����� �����, �� ������������ ������������. ��������� �������������� �������� (AttachedDevice):
��� � ��� ������ ������������� ������ � ���� �� ����������, � � ���� ��� ������ ���������.
� DDD aggregate route � ��������, ������� ������� ����� ���������. ��� ������� ������ ������ (Hotel); ��, �� ��� ����� �������� ��� ���������. � AttachedDevice ��� ����� ������ � ��� �� ����������, � �� �� ����� �������� ������. ��� �� � ������ Room � Reservation �� ����� �������� ������, ������ ����������� �� Hotel. ������� ������ �� ���� ���� ������� � ������������� ����� ������� ��������, ����� Hotel, � ������ ������. Device �� � ������ route � ������ ������, ������ ������ � ������ ������� �����.
����, ���� �� ���������, ��� ���� �������� � ��� ������ � ���� ������ �������, ������ ��������� �� � � ��� ����� ����� ���� �������� ������-��������. � AttachedDevice �����, ��������, ���� � ������� �������, � � Device ����� ���� �� �����.
� ��� ������� ��������, ��� ��� ����� ��������� � ����� �������� ������:
- PUT /hotels/555/rooms/105/attachedDevices � �������� ��� ��������� ����������� ��������� �� �����.
- POST /hotels/555/rooms/105/attachedDevices � ��������� ��� ���� ����������.
- DELETE /hotels/12 � ������� �������� ����� � >
CQRS � Command Query Responsibility Segregation
� �� ���� ������ ������������ ��� ��� �����������, �� ���� ������� ����������, � ��� �� ������� ��������. ����������� CQRS �������� �� ���������� ������� ������.
� ��� ���� ���� �����, ����� ������� ������������ ���������� �� ������ ������� �� ��������� ������. ������ �� ����, ��� ��������� ������������� ����������, � ������������ �� ��������� ������� ���������������. ����, ����� ���� ��� ������������ �������� ������� �� ��������� ��������, ������ �� ������������ � ������������� � �����-�� ������, ������� �������������� �� ������ � UI ��������� ���.
����� ������ �������� ��� ��������� ��������� REST ����� �����. ���� ���� �������, ������, ���� �������� ������� ������.
REST without PUT
� ������� CRUD-���� PUT � ��� �����, ������� ������ �������. �� ���� �� ������ ������� �������� CQRS � ������ ��� ����� �������, PUT � ��� ���������, �. �. �� �� ����� ������ �������. ������ ����� ����� ���� ������� ������� ������� �� ���������. ��� ���� ����� ����������� ������ ����������, �������� ������� (DELETE), ����� ������� ������� ���������, � ������������ ������ �� ��������, � ������ �������� � ����������.
��������� REST without PUT � ���� ��� ������� � �� �� ����� �����������, �� ��� �����-�� ������� ������������� ������ ���������.
Fine-grained VS coarse-grained
�����������, ��� �� ������� ������� ������, ������� ������. ��� � ��� ���� ��� �������: fine-grained API � coarse-grained API (��������������� � ���������������� API).
Fine-grained API:
- ����� ��������� ��������.
- ������-������ ������ �� ������� �������.
- ����� �����, ��� ������� �������.
- �������� ������ ���������.
- ������ ������ ��������� ���������, ��������
- POST /blogs/
/likes.
- POST /blogs/
- ����� ����������� ��������� �� �������.
- ������� ������� ������ ��������� ��������.
��� ������ ������� ������������� fine-grained API: ������ ���, ����� �� �������� ������, ����������� ��� �� ������. �� ������ �������� �� ������� ������� ���������� ��������� � �������. ������ � ���������� ���������� �������� �����, ��� � ��������: ���� �� �������� ������� ��������, ��� ������ ����� ����� �� ���������, ������ ����� ������ ��������� ��������� � ����������� �� ��� ����������� �����. �. �. ����� �������� � ��������� ��������� � ���������� �� ���������.
��������� ������
��� �� ���������, ��� � ���������� � ��� � ������� ����� ������������� ���������. ������-�� ���� �������, ���, ���� ��� ����� � ������� API, ��� �� API, � ������� ��� ����� ������ ��� ������. �� ��� �� ���. ���� �� �����-�� �������� API � ������ ��� ���� ������ �����������, ��� � ��� ������ 1.0. ����� ��������� ������ ������ ��������� � ��������� ������. ���� ���� ����� ����������� ���� ��� � ��� ������, ������� �� �� ������������.
�� ������� ������� ����������� ��������� ��� ���������� API ����� ������ ������, ��� �� ��� ����� ������� � �� �������� ���� ������, �� ������ ��� ����� ���������� � ������ �����.
����� �������� �� ������� ������ �������� ��������� ������ Web API?
����� ������� � ������� ������ � URL.
��� ������� ��������, ����� ������ ������ ������ �� ����:
��� ���� ���������� ������� �������.
��� ����� ���� ������� ��������� � constraint � ���� �� ������ �����-���� ��������� �������, ��������� ������ constraint. �� ������ ������ � ���� �������� ������ ������ ����������� constraint. ��������������, �� ���� � ��� �� ������� � ������� ��������, �� ���������� ������ ����������� ������� �� ��� ������ ������ � ���������� ������ ������. ��� �������� ��� �������.
��� ������, Swagger ������� ���, ��� � ��� ����, ������� XML-�����������.
���� � ������ �������� ������ GET. ���� ������ �� ������, �� �� � ����� ���� �������� � ������ ���������.
� ��� ��� �������� ������������ � POST, ������ �����:
��� ������ �����:
���, ��� ���� �������� � XML-������������, � �����.
����� �����
�������������� ���������� ������� ��� ��� ����� �� ������������ ���������� ������, ��������� ������ �������� ���������. ������� ��� �������� �����, ������������ ���������� ���������. �� ��� ������� ���������� �����, ���� �� �� ������������ ����, � ����� ���� �������� ��� ����������� �������� �������, ������������ �� ���������� ��� ������������� � �������������? ��� ����� ����� �� ���� ������ ��� ����������� ������ � �������� �������, ��� �������� ������� ��� ����� ��������, � ������������� ���� ��� �� �������.
������ �����, �� ������ ��� ����� ��� ����� � ������� ����� ��������, ��� ��� ������ � ���� ��������� �������� ����, � ������, � ���������� ������ � ������ ������� ���, ��� ��� ������ ��� �����, ������� ��� ����� � ������������ ��, ������� ������� ���� � ����������� ������. �� ���, ������, ������� ������ �� ������� ��� ����� ������ ����, � ����� ����� ��� ����������������, ������� � ���� ���������� ��, ��� ��� ����� �� ��� ���� ������ � ���� �������������� ����������, ��� ���������� ��� ���������, ��� ��������� ����, ��������� ���� ������ � ������������ ������������ ������.
� ������ ����� ���� ���� ��������, ���������� � ���� SAP Business One. �� ��������, �������, ������� ��������� � ����������� ����������. ���� ����, ����������� ����� ������ ������������ ��������� ������, ���������� � ������������ ���� ����������� � ������� ������������ ���������, ����������� � �������, ������������� � ������� ����� �������� �������, �� ��������� ��������� �������� ������ � ������� ���������������� ����������� ��������, �� ����������� ����������� ����� ��� ��������� ��� ������.
�������� ����� ��������� �������� � ���������� ����� ������� ��� �������; ������� ������ � ������� ����������� ��������� ����������; ����������� � ������ ����� ��� ������� ��������� ��� ������������ ���������� ��������.
�������� �����, �� �������:
� ��� ������� �������, ����� �������� ������� � �������������� ������ �������, �� ����� ������� ������ ����������� ���������������;
� ����� ������ ������� � ���������� ������������� � ����������������, ����� ���������� ���������� ������� ��������� ��� ������ ������������� ������ ��������;
� ��� ����� �������������, ������ �������� ������� �������������� ��� ���������� ��������;
� ��� ���������, �������, ������������� � ��������� �������� �������� ��������;
� ��� �������� ������� ������� � ������������ �����������.
XXXIX. ������� Hyperwave API
Hyperwave ��� ���������� IICM � Graz. �� ��������� ��� Hyper-G � ������ �������� �� Hyperwave ��� ���������������� (��������� �����, ��� ���� � 1996).
Hyperwave ��� �� ���������� ���������. ������� ������, 5.5, �������� �� www.hyperwave.com. ����� ��������� ��������� ������ � ������������ �������� ������������� (30 ����).
Hyperwave ��� �������������� �������, ����������� database (HIS, Hyperwave Information Server). ��� ������������� �� �������� � ������������ ����������. ���������� ����� ���� ����� ���� ������, ������� ����� ����������� � �����. ������ �������� �������������� ������� �������. ������ �������/object record �������� ���������� ���������. ���������� ��� ������ ���������, ������� ����� ���� �������� �������������. ��������� �������� ������ ��������������� Hyperwave-��������, ������ ����� ���������������� �������������.
� 2001 �. �������� Hyperwave SDK. �� ������������ Java, JavaScript � C++. ������ ���������� PHP ���������� �� ���������� C++. ����� ������������ ��������� hwapi � PHP, �� ������ ������� ���������� Hyperwave SDK � ���������������� PHP � ������ —with-hwapi= .
API, ��������������� ����������� HW_API, �������� ��������� ��������-���������������. �� ����� ����� �� ��������� C++ Hyperwave SDK. �� ������� �� ��������� �������.
��������� ������� ������ ����� HW_API_String , HW_API_String_Array , etc., ������� ������� � Hyperwave SDK, �� �����������, ��������� PHP ����� ��� ��� ����������� ������.������ ����� ����� �����, ��� �������� ��������� ����� ��� �������� �� Hyperwave SDK. �������� ���������� ����� ������� ���������� �� ���� ������ ���������� PHP � ���������� C++ API ������ HW SDK. ������ �������� ��������� ����������, ��� ��� ���������� � ������������� ������ � ���������� ��� ���� ��������. ����� ������ ��������� ������, ������������������� � HW SDK. ����� ��������� ����������� ����. ���� ���������� ������ ���������, ��� ����� ���������������, ���� ��� ����������.
objectIdentifier — ��� ��� id �������, ��������, «rootcollection», «0x873A8768 0x00000002».
parentIdentifier — ��� ��� id �������, ������� ��������� ������������.
object — ��������� ������ HW_API_Object.
parameters — ��������� ������ HW_API_Object.
version — ������ �������.
mode — ������������� �������� — ������ ���������� ��������.
attributeSelector — ������ �����, ������ �� ������� �������� ��� ��������. ��� ������������, ���� �� ������������ ������ ������� � ������ �������� ��������� ��������.
objectQuery — ������ �� ����� ������������ ������� �� ������ ��������. ������������ ��� ���������� ���������� ��������, ���������� ��������� ����� hw_api->children() ��� hw_api->find() .
���������� � Apache �, ��������, ������� ��������� ��� ������� � ������ Hyperwave Modul, ������� ��� ������ ����������� ��� ���������� � Hyperwave Server.
��� ����� API? ������� ���������� ��� ����������
���� ������� ������ �� ����� � ����, ��� ���� ���-�� ����������� � �����������. �� ������ �� ��� ��������, ��� ������ �� ���������� � ����� �����. ����������� ϸ�� ������� ��������� �� API �������� ������� � ���� �����.
������������ API ���������������� ��� �Application Programming Interface� (��������� ���������������� ����������, ����������� ��������� ����������). ����������� ������� �������� �� ����������� ����� ������������� API ��� �������� ��� ��� ����������� �������������. ����� ������, ��� � ����� ������� API ����������� � ���������� � �������, ������� ����� �����������, ��� �������� ���������� �������.
��������� ������� � �������� �������
WWW ����� ����������� ��� �������� ���� ��������� ��������, �� ������� � �������� ������ ��������. ������� ������� ����� ���������� � ������, ��������� ����������� ����� ���� � ����, � ��������� ������� ������������ ���������� ��� �������� ������ ����� ���, ��� ������� �� ��� �������� ����� �������������.
��� �������� � �������� ������ �������� www.facebook.com �� �������� ������ Facebook ������������ ��������������� ������. ��� ������ ������� �������� �����, �� �������������� ��� � ���������� ��������.
������ ���, ����� ������������ �������� �����-���� �������� � ����, �� ��������������� � API ��������� �������. API � ��� ������������ ����� �������, ������� �������� ������� � ���������� ������.
API ��� ������ ������������ ��������
������ �������� ���������� API ��� ������� �������. ��������, Weather Underground ������ ������ � ������ API ��� ��������� ����������������� ������.
�������� �������������: �� ����� ��������� �������� ���� ����� ��� ������ �������� �� ����. �������� ����� �������� � ���� Google ���������, ����� ���� �������� ����������� ������������� ��������� ������� � ������� ������ � ����������� �������.
���������� API: ���� � ������ ����� ������ �������� ���������� � ������� Google � �������� �� �������� ������� � ���������� ��������, �������� ����� Google, ������������ ���, � ���������� ��������������� ���������� � �������, ��������, ��������� � �������� �� ������������� ������������.
� �������� ������������ ������� ����� ������� ������ � API ������� Google, ����� ������ ��������.
��� API Google ��������� ���������� �� API ������ ������� ��������� ������� � ����?
����������, ������� � ������� ������� � ������. ����� ������������� ������ ���-��������, ������� ������� ����� �� ����� �������� HTML, � �� ����� ��� API Google ��������� ����� ������ ������ � ������� ����� JSON.
���� ������ � API ������ ������ ���-����� ��������, �� �� � �������� �������� (��� ��, ��� �������� ��������� �������, ����� ������������ ��������� ���-����).
������������ ��������� API �������� ����������� ��������� ��������, �� ������� ���� ��������.
����������� ����������� ������ ���������� �� ������� ���� ��������� ��������� API. ������ ������ ��� ����� ������� �������, ������������ ���������� ��������������, ���� �� ���������� ��� ������. �������� ����� � ������� ���������� ������ � ��� �������� �������.
������ ������������ �������� ���������� �� ��������� ��������, ������� ��������������� ����� ����� ��� ������ API. �������, ������� ��������� ��������������� ������� �� ��������� � �������� ������� ����������, ���������� ��������������.
����� �������, ����� �������� ���������� ����� ������������� API, ��� ������ ��������, ��� ��� ������� ��� ����������� URL, ������� � �������� ������ ���������� ������ ������.
����� ������� ����� ����� ���������� ����� �������. ��� ��� �������� ������ �� ��������� HTTP ���������� � ��������� ����, ������� ������ ������ ���������� �����. ��������, ����� ������� ����� �������� ���������� � API GitHub (https://api.github.com/users/petrgazarov), ������ ��� ������� �������, � �������� ��� ����� ����� � ������� JSON:
������� ������� ���������� JSON-�����, ������� ������ ����� ��������� � ���. �� ������ ������ ���������� ������ ������� ������, ����� ������������ �� �� ������ ����������.
��� ��������� �������� API
����� �application� (����������, ����������) ����� ����������� � ������ ���������. � ��������� API ��� �������������:
- �������� ������������ ����������� � ����������� ��������,
- ������ �������, ���������� ������� ��� �� ������ ��������� ����� ����������.
����� �������� ��, ������� ����� ����� �������� �� ���������, ����� �������� ����� ��� � ������������ ������������, � ���� ����� ����� ���������� ���� API. ��������, ��� ��������� � ��� ������������� ��������� ����������, ��� ���������� ������ ����� ����������. ������ ��������������� ���������� ��, ���������� ����� ����� ����� API, ������� �������� �� ����������������� � ��������� ����� ����������.
� ��������-��������������� �������������� ��� ����������� � ���� ������������ ��������. � ���������� ����� ��������, ����������������� ����� �����, ����� ���� �����. � ������� �� ��� ���� ���� API � ����� ��������� ������� � ������� ��� �������������� � ������� ��������� � ����������. ������� ����� ����� ����� �������, ���������� ������, ������� ������ �� ��������� � �� �������� API.
hwapi_attribute_new
(Информация о версии неизвестна, возможно, только в SVN)
hwapi_attribute_new � Creates instance of class hw_api_attribute
Описание
Creates a new instance of hw_api_attribute with the given name and value.
Список параметров
The attribute name.
The attribute value.
Возвращаемые значения
Returns an instance of hw_api_attribute.