Facebook
Twitter
LinkedIn
YouTube
GitHub
Hasan's Blog
  • Home
    • About me
  • Hashicorp
  • Ansible
  • CI/CD
  • DevOps

CURD functions and REST api

2017/06/06Hasan YousufUncategorized

CURD functions and REST api

Curd functions are synonymous of modifying the information in the database world. If you have heard the CRUD before. It means create, Read, Update & delete. Level 2 of Richardson maturity level is about matching services with their HTTP Verbs. CRUD functions are mapped to their HTTP equivalents. So, we use

  • Create = POST
  • Read = GET
  • Update = PUT
  • Delete = DELETE

Often times, people will use POST for Create and Update because of return types PUT allows.

JSON

  1. JSON stands for JavaScript Object Notation
  2. By the way, it is pronounced as “Jason”
  3. It is preferred when working with JavaScript clients
  4. It is looser way to represent data
  5. It is Flexible and easy to work with
  6. The most common reason, people use JSON. JSON is not XML. There are lot of good things that XML brings to the table. If you donot need it, JSON just works fine and if your clients are only going to be consumed or your clients are using only JavaScript. It makes sense to use JSON. There is no need to package something in XML. Send that down to a JavaScript client. Have it start with the parser and go through that.
  7. It is difficult to validate JSON. There is no way to through and say ‘It is valid JSON’.

To use JSON all we have to do to annotate our method Produces like

@Produces(MediaType.APPLICATION_JSON)

It tells us that application is producing JSON

XML

  1. XML offen associated with SOAP
  2. It is still great solution for REST
  3. REST does’t mean unstructured
  4. It is easy to validate, confirm well formed. We can put schema and structure around it so we know what we are navigating.
  5. To use XML, all we have to do annotate our method Produces like
@Produces(MediaType.APPLICATION_XML)

Binary

Binary is not necessarily an alternative to JSON or XML
It is used to serve objects. e.g.,

Files
Images
PDFs

Here I does mean JAVA objects, binary things we normally serves statically or that are stored in your database. To use binary we annotate our method Produces like

@Produces(MediaType.APPLICATION_OCTET_STREAM)
Previous post Delete docker images & containers in one command Next post VirtualBox fails with “Implementation of the USB 2.0 controller not found”

Categories

  • Casperjs (1)
  • CI/CD (4)
  • DevOps (6)
  • Gruntjs (2)
  • Jira (1)
  • Linux (1)
  • Programming (1)
  • Uncategorized (14)
  • VMware (1)

Archives

  • May 2020 (1)
  • April 2020 (1)
  • March 2020 (2)
  • September 2019 (2)
  • May 2018 (1)
  • September 2017 (3)
  • July 2017 (1)
  • June 2017 (4)
  • May 2017 (1)
  • July 2015 (2)
  • January 2015 (1)
  • October 2014 (1)
  • September 2014 (5)
  • August 2014 (1)

Tags

Arduino Arduino sketch Arduino sketch upload bash shell casperjs Couchdb Curl docker container docker images github Gitlab gnu Parallel gruntjs JAVA JAVA jenkins Jira JPA Json Linux linux mint Maven mint MYSQL Tomcat Ubuntu Version Control xpath
  • Home
    • About me
  • Hashicorp
  • Ansible
  • CI/CD
  • DevOps
@2017
Manage Cookie Consent
We use cookies to optimize our website and our service.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
Preferences
{title} {title} {title}