R
R
rFczZZ2016-07-10 07:51:38
PHP
rFczZZ, 2016-07-10 07:51:38

Rest api: what link to use for preview?

Please tell me which interface to use for validation and preview BEFORE creating or updating a record.
It is necessary that the user sees what he is typing with bb codes or markdown or some other complex markup. Accordingly, the model has two fields Text and RawText and only the server can make Text from RawText.
Ideally, there should be some kind of request in the body of which there will be only a model with empty fields. For example, to create, I could use
POST resources/with_empty_id
or
GET resources/with_empty_id,
but the get on the collection should return the collection itself, and the post will create/modify the record in the database.
It turns out that you definitely need to have something in the style:
GET resources/preview
Or with additional parameters in the request body? I also thought about the option with sessions (temporary id for records), but then some kind of passive service should be spinning that would clear expired sessions, I don’t have the opportunity to use this yet.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
coderlex, 2016-07-13
@rFczZZ

Request to create/modify POST/PUT /resource_name + custom header like X-Validate. By its presence, the server API could determine whether only validation is required or whether the resource is actually saved.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question