当前位置:网站首页>Chapter V Modification implementation (impl) class
Chapter V Modification implementation (impl) class
2022-07-24 10:17:00 【yaoxin521123】
List of articles
The fifth chapter Modify implementation (IMPL) class
This chapter discusses how to modify REST The implementation class of the service .
Initial method definition
Implementation classes initially contain stub methods , As shown in the following example :
/// Returns all pets from the system that the user has access to<br/>
/// The method arguments hold values for:<br/>
/// tags, tags to filter by<br/>
/// limit, maximum number of results to return<br/>
ClassMethod findPets(tags As %ListOfDataTypes(ELEMENTTYPE="%String"), limit As %Integer) As %Stream.Object
{
//(Place business logic here)
//Do ..%SetStatusCode(<HTTP_status_code>)
//Do ..%SetHeader(<name>,<value>)
//Quit (Place response here) ; response may be a string, stream or dynamic object
}
In each case , These stub methods all follow REST The signature of the contract defined by the service specification .
Implementation method
For each method in the implementation class , According to the REST Call edit method definition ( Especially the realization ). Please note that , This method is preceded by a comment , The note is corresponding REST A copy of the call description . In practice :
- Return the appropriate value .
- Check the request message . So , Please use the implementation class
%CheckAccepts()、%GetContentType()and%GetHeader()Method . All the methods mentioned here are from%REST.Implinherited , It is a superclass of your implementation class . - Set as needed
HTTPStatus code to indicate , for example , Whether resources are available . So , Please use%SetStatusCode()Method . ofHTTPStatus code information , see also http://www.faqs.org/rfcs/rfc2068.html. - Set up
HTTPResponse headers . So , Please use%SetHeader()、%SetHeaderIfEmpty()and%DeleteHeader()Method . - if necessary , Report error . So , Please use
%LogError()Method .
Expose the details of the server error
By default , If REST The service encountered an internal error , The details of the error will not be reported to the client . To change this , Please add the following to the implementation class , Then recompile it :
Parameter ExposeServerExceptions = 1;
Please note that , default %ReportRESTError() Method will check this parameter . If you override this method ( See the next title ), You can choose whether the method uses this parameter .
Modify the error response
If you need to format the error response in a non default way , Please override %ReportRESTError() Method . In the method , Use %WriteResponse() Method returns an error response .
边栏推荐
- error: field ‘XXX’ declared as a function
- Mysql InnoDB下联合索引的索引数量?
- Arduino- how to light the LED?
- Can the "self-help master" who has survived the economic crisis twice continue to laugh this time?
- SMTP automatic mail sending function code
- ffmpeg花屏解决(修改源码,丢弃不完整帧)
- AttributeError: module ‘sipbuild. api‘ has no attribute ‘prepare_ metadata_ for_ build_ wheel‘
- Use of jstack "JVM common commands"
- Source insight 3.5 comment garbled
- [robot learning] mechanism kinematics analysis and MATLAB simulation (3D model +word report +matlab program)
猜你喜欢

Dynamic programming -- a collection of stock problems
![[STM32 learning] (16) STM32 realizes LCD1602 display (74HC595 drive) - 4-bit bus](/img/8f/19b0eb959d2b3f896c8e99f8e673d1.png)
[STM32 learning] (16) STM32 realizes LCD1602 display (74HC595 drive) - 4-bit bus

zoj-Swordfish-2022-5-6

Intranet remote control tool under Windows

Web page opening speed is very slow, how to solve it?

Mysql database JDBC programming

Add SSH key to bitbucket

The concept and representation of a tree

Homologous policy solutions
![[correcting Hongming] what? I forgot to take the](/img/41/c8fa6380ab63949ae6d904fdbb005c.png)
[correcting Hongming] what? I forgot to take the "math required course"!
随机推荐
图模型2--2022-5-13
JS 84*148=b6a8 how many decimal places can you make both sides equal
Jenkins deploys the project and prompts that the module package defined by him cannot be found
Knapsack problem of dynamic programming -- three lectures on knapsack (01 knapsack, complete knapsack, multiple knapsack)
CRC Coding in C language
JS bind simulation
Will not be rejected! Learn the distributed architecture notes sorted out by Alibaba Daniel in 35 days, with a salary increase of 20K
Redis configuration serialization
Wechat applet
Synchronized scope "concurrent programming"
Implementation and traversal of binary tree and binary tree sorting tree
Activity exception lifecycle
Erlang学习番外
The best time to buy and sell stocks includes handling charges (leetcode-714)
Basic SQL operations
Google Earth engine - QA in Landsat 5 toa dataset_ Pixel and QA_ Radsat band
第五章 修改实现(IMPL)类
Web page opening speed is very slow, how to solve it?
Erlang学习01
LiteOS_ a - SYS_ The run() function is missing a header file.