api-design

Can I PUT without an ID?

喜你入骨 提交于 2019-12-07 08:18:56
问题 I'm designing an API Rest service that allows the user to upload a file to the server. I'm thinking this is a PUT request and it would go to server/resource/ID and have the file as base64 in the json request body. My question is regarding this ID. In my head, I'm passing the file to the server and the server should be in charge of storing that file and generating a unique ID to retrieve it later, and then return this ID to the client with an ok status. So I'm thinking about doing that,

Return data from Laravel Jobs

血红的双手。 提交于 2019-12-07 05:09:20
问题 I am developing API on Laravel for mobile application. Methods will make requests to other API's , combine and filter data, changing it's structure etc. One of the requirements to app is to respond no more than 30 seconds, or not respond at all. So, I have to repeat requests as much as I have time. I trying to realize that with Laravel Queues, and currently have something like that in my Job class: private $apiActionName; public function __construct($apiActionName) { $this->apiActionName =

Why is JavaMail Transport.send() a static method?

拥有回忆 提交于 2019-12-06 22:55:53
问题 I'm revising code I did not write that uses JavaMail, and having a little trouble understanding why the JavaMail API is designed the way it is. I have the feeling that if I understood, I could be doing a better job. We call: transport = session.getTransport("smtp"); transport.connect(hostName, port, user, password); So why is Eclipse warning me that this: transport.send(message, message.getAllRecipients()); is a call to a static method? Why am I getting a Transport object and providing

Strings or URI in .NET APIs?

烂漫一生 提交于 2019-12-06 19:16:48
问题 I am writing an .NET wrapper API for the Netflix API. At this point I can choose to represent URLs as either strings or URI objects. Seems to me there is a good case for both. So if you were using an API, which would you prefer? 回答1: The below quote is from: Framework Design Guildelines I highly recommend this book to anyone developing frameworks on .Net Do use System.Uri to represent URI / URL data. (For Parameters, properties, and return values) System.Uri is a much safer and richer way of

Is an API endpoint that differentiates what resources to return based on user credentials RESTful and good URI design?

血红的双手。 提交于 2019-12-06 17:10:54
问题 Important note The focus of this question is on API endpoints that differentiate which resources are returned depending who authenticates , e.g. Alice gets resource A and B returned, and Bob gets resource X and Y. It is NOT about differentiating the representation of resources returned. All the endpoints return JSON representations of resources. Preface Please consider the following three potential API endpoint designs, all returning thing resources of a user. Endpoint A GET /things If

Why can't AtomicBoolean be a replacement for Boolean?

家住魔仙堡 提交于 2019-12-06 16:32:49
问题 The Oracle JDK Javadoc for AtomicBoolean states: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicBoolean.html A boolean value that may be updated atomically. See the java.util.concurrent.atomic package specification for description of the properties of atomic variables. An AtomicBoolean is used in applications such as atomically updated flags, and cannot be used as a replacement for a Boolean. A colleague and I were trying to figure out a use-case where the

Why doesn't FileExists support wildcards?

南笙酒味 提交于 2019-12-06 13:47:55
Consider this example VBScript fragment: Dim fs Set fs = CreateObject("Scripting.FileSystemObject") If fs.FileExists("D:\Folder\File*.ext") Then ' Finds nothing! fs.CopyFile "D:\Folder\File*.ext", "D:\OtherFolder\" fs.Deletefile "D:\Folder\File*.ext" End If The FileExists method turns out not to support wildcards ( * and ? ). Not does FolderExists . I expected wildards to just work because they work fine for all similar methods in the FileSystemObject : CopyFile , CopyFolder , MoveFile , MoveFolder , DeleteFile , DeleteFolder and the Get* filename handling methods like GetAbsolutePathName . Of

Using Javascript loop to create multiple HTML elements

﹥>﹥吖頭↗ 提交于 2019-12-06 13:32:09
问题 I would like to use a javascript loop to create multiple HTML wrapper elements and insert JSON response API data into some of the elements (image, title, url, etc...). Is this something I need to go line-by-line with? <a class="scoreboard-video-outer-link" href=""> <div class="scoreboard-video--wrapper"> <div class="scoreboard-video--thumbnail"> <img src="http://via.placeholder.com/350x150"> </div> <div class="scoreboard-video--info"> <div class="scoreboard-video--title">Pelicans @ Bulls

How to handle the introduction of a new object property in a REST API

夙愿已清 提交于 2019-12-06 08:25:35
问题 I have a public REST API that, among all the exposed resources, exposes these: POST my/webservice/foos/ PUT my/webservice/foos/{fooId} both resources use a JSON model like the following: { "a": "a mandatory string", "b": "another mandatory string" } So, every time a user creates a new Foo or updates an existing one, he will have to specify both the new a and the new b. So far, so good. Now, suppose that a Foo has actually more than those two properties, say it has also a string "c", for the

Choosing between package:html, dart:html, dart:io (class HttpClient) and package:http APIs to fetch HTTP resources

你。 提交于 2019-12-06 08:02:52
问题 I realized that currently there are at least three "official" Dart libraries that allow me to perform a HTTP request. What is more, three of those libraries (dart:io (class HttpClient), package:http and dart:html) have each a different, incompatible API. As of today, package:html does not offer this functionality, but on its GitHub page I found it aims for 100% API compatibility with dart:html, so these methods will be added there eventually. Which package provides the most future proof and