#1 2021-04-04 09:13:30

JD
Member
Registered: 2015-08-20
Posts: 101

Returning standard REST API codes e.g 200, 201, 404 etc

Hello there everyone,

I need a little clarification concerning the way the mORMot framework returns the standard REST codes e.g 200, 202 , 204, 404 etc.

I want to look for these codes in the messages received from my mORMot server by the RESTful clients of my application (Java & Lazarus/FPC) and display appropriate messages to the users.

How do I implement this functionality in my mORMot server and where do I look for the codes in the messages sent by the server to my clients?


Thanks a lot for your kind assistance.

JD

Offline

#2 2021-04-04 15:04:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,263
Website

Re: Returning standard REST API codes e.g 200, 201, 404 etc

Please check the documentation.

Method-based services handle any kind of return code, as you want.
https://synopse.info/files/html/Synopse … #TITLE_349

Interface-based services are usually abstracted from REST/HTTP codes.
They may called outside of the HTTP/REST protocol, e.g. directly in-process on server side.
So you should better not rely on HTTP/REST codes with interface based services.
Check https://synopse.info/files/html/Synopse … l#TITL_165

TL&LR: do not rely on HTTP codes, but return 200 on normal status, and an error code as integer enumeration, optionally with a textual/English error message.

Offline

Board footer

Powered by FluxBB