freme-project / Broker

FREME Broker
Apache License 2.0
2 stars 0 forks source link

Test: General #13

Closed jnehring closed 9 years ago

jnehring commented 9 years ago
andish commented 9 years ago
fsalliau commented 9 years ago

+1 for API uniformity. Andis, do you mean we should abandon any GET requests?

andish commented 9 years ago

Yes, I think for enrichment services we could deny any GET request to avoid problems and provide all services in a single way:

For metadata issues (that are now uploaded separately from the NIF content) - maybe we have to find a way how to include them into the RDF (NIF) document, to be in line with common approach.

m1ci commented 9 years ago

Andis, do you mean we should abandon any GET requests?

The correct way is to submit data as body of a POST request, however, GET requests are VERY handy for developers and consumers because you can directly in your browser test the service. Note that by entering URL address in any browser is translated into a GET request. I suggest we support POST (primarily) and GET request (optionally).

jnehring commented 9 years ago

I see that putting only the NIF string in the POST body and defining the NIF serialization format using Content-Type header is the RESTful way and therefore clean API design. But in some cases this API design is not possible:

  1. Sometimes we might want to put multiple variables in the POST body. To my knowledge this is only possible with Content-Type: multipart/form-data or application/x-www-form-urlencoded
  2. We already have use cases with multiple variables in the POST body: e-Publishing needs to accept files and nif as input. We discuss to append a SKOS file to an e-Entity request in addition to the NIF data.

So there are e-Services that require Content-Type multipart/form-data or application/x-www-form-urlencoded. For uniform e-Service design I suggest that we use the same Content-Type for all POST requests.

I would not drop GET requests completely. They are useful for non-expert users who dont know about HTTP details. They require less configuration and can be tried out using the web browsers address bar. Our e-Services should accept the same parameters both from query string and POST body.

m1ci commented 9 years ago

Sometimes we might want to put multiple variables in the POST body. To my knowledge this is only possible with Content-Type: multipart/form-data or application/x-www-form-urlencoded

Don't understand the term multiple variables? you mean query parameters?

We already have use cases with multiple variables in the POST body: e-Publishing needs to accept files and nif as input. We discuss to append a SKOS file to an e-Entity request in addition to the NIF data

We define APIs which (almost) always are defined as a set of resource URIs. So, for the e-Publishing API you can have 1) resource defined for submitting the metadata (I think these are the files you are talking about) and 2) a resource for the main NIF document.

Examples:

POST /e-publishing/metadata/documents/

for submitting the metadata documents, and

POST /e-publishing/ebooks/documents/?metadata=some_id_here

for submitting the NIF which will be then converted to a eBook using the metadata files submitted in the previous call.

What do you think?

jnehring commented 9 years ago

About the term multiple variables: Here are two examples of POST requests with two variables in the body. Both encode two variables with variable1=value1 and variable2=value2. Note that the request body starts after the empy line after Content-Type.

POST /e-entity/dbpedia-spotlight HTTP/1.1
Host: rv1460.1blu.de:8080
Content-Type: multipart/form-data

----WebKitFormBoundaryE19zNvXGzXaLvS5C
Content-Disposition: form-data; name="variable1"

value1
----WebKitFormBoundaryE19zNvXGzXaLvS5C
Content-Disposition: form-data; name="variable2"

value2
----WebKitFormBoundaryE19zNvXGzXaLvS5C

or

POST /e-entity/dbpedia-spotlight HTTP/1.1
Host: rv1460.1blu.de:8080
Content-Type: application/x-www-form-urlencoded

variable1=value1&variable2=value2

About having two endpoints for the same call: One principle about RESTful API design is that it is stateless. When we use two API calls for one function then it is not stateless. Also it complicates our codes a lot when one API call references to another API call and we have to store intermediate results somehow in the broker. When someone uploads a file then we should process the file and get of it as soon as possible so it does uses the servers memory as short as possible.

andish commented 9 years ago

When we use two API calls for one function then it is not stateless.

Not always true. If you use any DB that stores previously uplouded part of request it is still stateless webservice and can be balanced.

But - I think that multipart uploud should leave as any advanced service variation, primary e-services could accept normal POST request.

We have to think about simple and widely reusable services and not let the tehnologies and some issues lead us to hardly usable services.

jnehring commented 9 years ago

We agreed on encoding only NIF content in post body instead of using multipart post requests. The discussion about parameter names moved to #14