SlideShare une entreprise Scribd logo
1  sur  21
REST Easy with AngularJS 
ng-grid CRUD EXAMPLE 
Relly Rivlin – Co-founder and VP R&D 
relly@backand.com 
10/5/2014 1 www.backand.com
www.backand.com 
Agenda 
• First…REST overview 
• And then, Angular core services 
• What you’ll get at the end, CRUD with ng-grid
www.backand.com 
REST Overview 
• What is REST 
‹ Representational state transfer 
‹ General architecture 
− Stateless 
− Uniform interface 
− Client server 
• What is RESTFUL 
‹ Implementation over HTTP for web services 
‹ Simple object driven vs. action driven API 
• Request and Response examples
www.backand.com 
Request 
• URI routing part: 
{[version]}/api/{object|class|collection|table}/{[id]} 
‹ /1/api/car/711 
‹ /1/api/car?doors=4 
• Querystring is usually for filtering, sorting and paging 
• HTTP verbs for CRUD 
• Headers
www.backand.com 
Verbs 
Resource GET 
read 
POST 
create 
PUT 
update 
DELETE 
/car 
Returns a list 
of cars 
Create a new car Bulk update of cars Delete all cars 
/car/711 
Returns a 
specific car 
Method not 
allowed (405) 
Updates a specific 
car 
Deletes a 
specific car
HEADER FIELD 
NAME 
Accept Content-Types that are acceptable for the response Accept: text/plain 
www.backand.com 
Headers 
DESCRIPTION EXAMPLE 
Accept-Charset Character sets that are acceptable Accept-Charset: utf-8 
Accept-Encoding List of acceptable encodings Accept-Encoding: gzip, deflate 
Accept-Language List of acceptable human languages for response Accept-Language: en-CA 
Cookie an HTTP cookie previously sent by the server with Set-Cookie Cookie: $Version=1; Skin=new; 
Content-Length The length of the request body in octets (8-bit bytes) Content-Length: 348 
Content-MD5 A Base64-encoded binary MD5 sum of the content of the request body Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ== 
Content-Type The MIME type of the body of the request (used with POST and PUT requests) Content-Type: application/x-www-form-urlencoded 
Date The date and time that the message was sent Date: Tue, 15 Nov 1994 08:12:31 GMT 
Authorization Authentication credentials for HTTP authentication oauth_token="ad180jjd733klru7" 
WWW-Authenticate: OAuth realm="http://sp.example.test/" 
Indicates the authentication scheme that should be used to access the 
requested entity 
WWW-Authenticate
www.backand.com 
Response 
• The HTTP response is usually JSON 
• Status/Errors 
• CORS, JSONP
www.backand.com 
Status/Errors 
HTTP Verb Specific Item (e.g. /car/{id}) Entire Collection (e.g. /car) 
200 (OK), list of customers 
Use pagination, sorting and filtering to navigate big 
lists 
200 (OK), single customer 
404 (Not Found), if ID not found or invalid 
GET 
404 (Not Found), unless you want to update/replace 
every resource in the entire collection 
200 (OK) or 204 (No Content) 
404 (Not Found), if ID not found or invalid 
PUT 
201 (Created), 'Location' header with link to: 
/customers/{id} containing new ID 
POST 405 (Not Allowed) 
404 (Not Found), unless you want to delete the whole 
collection—not often desirable 
200 (OK) 
404 (Not Found), if ID not found or invalid 
DELETE
www.backand.com 
CORS, JSONP 
• CORS (cross-origin resource sharing) 
‹ Recommended if no need to support older browser versions 
‹ Server side only, by providing sets of headers supported by browsers 
‹ Enables secure cloud services for organizations 
• JSONP 
‹ Server and client side 
‹ P stands for padding 
‹ Pad the JSON with a function to overcome restrictions and remove it later
Angular Key Services for REST 
www.backand.com 
• $http and $resource 
‹ Ajax calls 
• $q 
‹ Async progress
$http and $resource 
• In this presentation we use $http 
• Key differences 
‹ $resource provides additional abstraction level 
‹ URI template 
‹ Function names 
‹ Parameters declaration 
www.backand.com 
• $resource example
Angular Service with $resource 
List service (filter, sort, paging) Item service (CRUD) 
www.backand.com
www.backand.com 
$resource Usage
www.backand.com 
$q 
• Monitor asynchronous progress 
• Promise
Prerequisite for the CRUD Demo 
www.backand.com 
• Angular 
• ng-grid 
• Backand REST API 
‹ Gives you security, web hooks, business rules, hosting and logging 
‹ Enables you to focus entirely on the client side
ng-grid CRUD with REST 
www.backand.com 
• Authentication 
• Read 
• Create & Update 
• Delete
www.backand.com 
Authentication 
• Get Oauth2 token 
• Add it to all the request 
headers 
• Using the $q promise
www.backand.com 
CRUD - Read 
Prepare $http functions Authenticate then read and set the 
data into the controller scope
CRUD – Create and Update 
Prepare $http functions In the ngGridEventEndCellEdit, prepare the 
JSON. If new row Create otherwise Update. 
www.backand.com
www.backand.com 
CRUD – Delete 
Prepare $http functions Go through all the selected rows and 
delete them by ID
www.backand.com 
Thank You! 
Github: https://www.backand.com/get-started 
Blog: http://blog.backand.com/ng-grid-real-rest/ 
Plunker: http://plnkr.co/edit/6jdCzZ?p=preview 
Directives: http://blog.backand.com/documentation 
Me: relly@backand.com

Contenu connexe

Tendances

How to build a rest api.pptx
How to build a rest api.pptxHow to build a rest api.pptx
How to build a rest api.pptxHarry Potter
 
Introduction to RESTful Webservices in JAVA
Introduction to RESTful Webservices  in JAVA Introduction to RESTful Webservices  in JAVA
Introduction to RESTful Webservices in JAVA psrpatnaik
 
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey IntroductionseyCwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey Introductionseyelliando dias
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVCIndicThreads
 
REST & RESTful Web Service
REST & RESTful Web ServiceREST & RESTful Web Service
REST & RESTful Web ServiceHoan Vu Tran
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web servicesnbuddharaju
 
RESTful services
RESTful servicesRESTful services
RESTful servicesgouthamrv
 
REST in AngularJS
REST in AngularJSREST in AngularJS
REST in AngularJSa_sharif
 
REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)Jef Claes
 
Learn REST in 18 Slides
Learn REST in 18 SlidesLearn REST in 18 Slides
Learn REST in 18 SlidesSuraj Gupta
 
Restful webservice
Restful webserviceRestful webservice
Restful webserviceDong Ngoc
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSCarol McDonald
 
The never-ending REST API design debate
The never-ending REST API design debateThe never-ending REST API design debate
The never-ending REST API design debateRestlet
 

Tendances (20)

How to build a rest api.pptx
How to build a rest api.pptxHow to build a rest api.pptx
How to build a rest api.pptx
 
Angularjs & REST
Angularjs & RESTAngularjs & REST
Angularjs & REST
 
Introduction to RESTful Webservices in JAVA
Introduction to RESTful Webservices  in JAVA Introduction to RESTful Webservices  in JAVA
Introduction to RESTful Webservices in JAVA
 
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey IntroductionseyCwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVC
 
REST & RESTful Web Service
REST & RESTful Web ServiceREST & RESTful Web Service
REST & RESTful Web Service
 
REST API Design
REST API DesignREST API Design
REST API Design
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
L18 REST API Design
L18 REST API DesignL18 REST API Design
L18 REST API Design
 
RESTful services
RESTful servicesRESTful services
RESTful services
 
REST in AngularJS
REST in AngularJSREST in AngularJS
REST in AngularJS
 
REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)
 
Learn REST in 18 Slides
Learn REST in 18 SlidesLearn REST in 18 Slides
Learn REST in 18 Slides
 
Restful webservice
Restful webserviceRestful webservice
Restful webservice
 
Rest web services
Rest web servicesRest web services
Rest web services
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RS
 
Implementation advantages of rest
Implementation advantages of restImplementation advantages of rest
Implementation advantages of rest
 
The never-ending REST API design debate
The never-ending REST API design debateThe never-ending REST API design debate
The never-ending REST API design debate
 
REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
 

En vedette

CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!Dan Allen
 
III - Better angularjs
III - Better angularjsIII - Better angularjs
III - Better angularjsWebF
 
Standardizing Our Drivers Through Specifications: A Look at the CRUD API
Standardizing Our Drivers Through Specifications: A Look at the CRUD APIStandardizing Our Drivers Through Specifications: A Look at the CRUD API
Standardizing Our Drivers Through Specifications: A Look at the CRUD APIMongoDB
 
SOA & APIs: Fearless Lessons from the Field
 SOA & APIs: Fearless Lessons from the Field SOA & APIs: Fearless Lessons from the Field
SOA & APIs: Fearless Lessons from the FieldCA API Management
 
From CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with SpringFrom CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with SpringVladimir Tsukur
 
rest without put
rest without putrest without put
rest without putXiaojun REN
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project Elad Hirsch
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJSInfragistics
 
Web api crud operations
Web api crud operationsWeb api crud operations
Web api crud operationsEyal Vardi
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architectureGabriele Falace
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni InturiSreeni I
 
Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web ServicesAngelin R
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS ArchitectureEyal Vardi
 

En vedette (16)

CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!
 
III - Better angularjs
III - Better angularjsIII - Better angularjs
III - Better angularjs
 
Standardizing Our Drivers Through Specifications: A Look at the CRUD API
Standardizing Our Drivers Through Specifications: A Look at the CRUD APIStandardizing Our Drivers Through Specifications: A Look at the CRUD API
Standardizing Our Drivers Through Specifications: A Look at the CRUD API
 
SOA & APIs: Fearless Lessons from the Field
 SOA & APIs: Fearless Lessons from the Field SOA & APIs: Fearless Lessons from the Field
SOA & APIs: Fearless Lessons from the Field
 
From CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with SpringFrom CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with Spring
 
Cqrs api v2
Cqrs api v2Cqrs api v2
Cqrs api v2
 
rest without put
rest without putrest without put
rest without put
 
Cqrs api
Cqrs apiCqrs api
Cqrs api
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 
Web api crud operations
Web api crud operationsWeb api crud operations
Web api crud operations
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architecture
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni Inturi
 
Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web Services
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
 
REST beyond CRUD
REST beyond CRUDREST beyond CRUD
REST beyond CRUD
 

Similaire à REST Easy with AngularJS - ng-grid CRUD EXAMPLE

Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 
Android App Development 06 : Network & Web Services
Android App Development 06 : Network & Web ServicesAndroid App Development 06 : Network & Web Services
Android App Development 06 : Network & Web ServicesAnuchit Chalothorn
 
Introduction to CloudStack API
Introduction to CloudStack APIIntroduction to CloudStack API
Introduction to CloudStack APIKrunal Jain
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.Andrey Oleynik
 
Architecting &Building Scalable Secure Web API
Architecting &Building Scalable Secure Web APIArchitecting &Building Scalable Secure Web API
Architecting &Building Scalable Secure Web APISHAKIL AKHTAR
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
Webservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTWebservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTPradeep Kumar
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with DropwizardAndrei Savu
 
Automating Cloud Operations: Everything You Wanted to Know about cURL and REST
Automating Cloud Operations: Everything You Wanted to Know about cURL and RESTAutomating Cloud Operations: Everything You Wanted to Know about cURL and REST
Automating Cloud Operations: Everything You Wanted to Know about cURL and RESTRevelation Technologies
 
RESTful web services with Groovy on Grails by Vugar Suleymanov
RESTful web services with Groovy on Grails by Vugar SuleymanovRESTful web services with Groovy on Grails by Vugar Suleymanov
RESTful web services with Groovy on Grails by Vugar SuleymanovVuqar Suleymanov
 
Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IWeb Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IAnuchit Chalothorn
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackChiradeep Vittal
 
HTTP Caching in Web Application
HTTP Caching in Web ApplicationHTTP Caching in Web Application
HTTP Caching in Web ApplicationMartins Sipenko
 

Similaire à REST Easy with AngularJS - ng-grid CRUD EXAMPLE (20)

Rest
RestRest
Rest
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 
Android App Development 06 : Network & Web Services
Android App Development 06 : Network & Web ServicesAndroid App Development 06 : Network & Web Services
Android App Development 06 : Network & Web Services
 
Introduction to CloudStack API
Introduction to CloudStack APIIntroduction to CloudStack API
Introduction to CloudStack API
 
Ws rest
Ws restWs rest
Ws rest
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.
 
Intro to CloudStack API
Intro to CloudStack APIIntro to CloudStack API
Intro to CloudStack API
 
Architecting &Building Scalable Secure Web API
Architecting &Building Scalable Secure Web APIArchitecting &Building Scalable Secure Web API
Architecting &Building Scalable Secure Web API
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
Webservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTWebservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and REST
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with Dropwizard
 
Web Services
Web ServicesWeb Services
Web Services
 
Automating Cloud Operations: Everything You Wanted to Know about cURL and REST
Automating Cloud Operations: Everything You Wanted to Know about cURL and RESTAutomating Cloud Operations: Everything You Wanted to Know about cURL and REST
Automating Cloud Operations: Everything You Wanted to Know about cURL and REST
 
RESTful web services with Groovy on Grails by Vugar Suleymanov
RESTful web services with Groovy on Grails by Vugar SuleymanovRESTful web services with Groovy on Grails by Vugar Suleymanov
RESTful web services with Groovy on Grails by Vugar Suleymanov
 
Restful webservices
Restful webservicesRestful webservices
Restful webservices
 
Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IWeb Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day I
 
06 web api
06 web api06 web api
06 web api
 
Doing REST Right
Doing REST RightDoing REST Right
Doing REST Right
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStack
 
HTTP Caching in Web Application
HTTP Caching in Web ApplicationHTTP Caching in Web Application
HTTP Caching in Web Application
 

Dernier

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 

Dernier (20)

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 

REST Easy with AngularJS - ng-grid CRUD EXAMPLE

  • 1. REST Easy with AngularJS ng-grid CRUD EXAMPLE Relly Rivlin – Co-founder and VP R&D relly@backand.com 10/5/2014 1 www.backand.com
  • 2. www.backand.com Agenda • First…REST overview • And then, Angular core services • What you’ll get at the end, CRUD with ng-grid
  • 3. www.backand.com REST Overview • What is REST ‹ Representational state transfer ‹ General architecture − Stateless − Uniform interface − Client server • What is RESTFUL ‹ Implementation over HTTP for web services ‹ Simple object driven vs. action driven API • Request and Response examples
  • 4. www.backand.com Request • URI routing part: {[version]}/api/{object|class|collection|table}/{[id]} ‹ /1/api/car/711 ‹ /1/api/car?doors=4 • Querystring is usually for filtering, sorting and paging • HTTP verbs for CRUD • Headers
  • 5. www.backand.com Verbs Resource GET read POST create PUT update DELETE /car Returns a list of cars Create a new car Bulk update of cars Delete all cars /car/711 Returns a specific car Method not allowed (405) Updates a specific car Deletes a specific car
  • 6. HEADER FIELD NAME Accept Content-Types that are acceptable for the response Accept: text/plain www.backand.com Headers DESCRIPTION EXAMPLE Accept-Charset Character sets that are acceptable Accept-Charset: utf-8 Accept-Encoding List of acceptable encodings Accept-Encoding: gzip, deflate Accept-Language List of acceptable human languages for response Accept-Language: en-CA Cookie an HTTP cookie previously sent by the server with Set-Cookie Cookie: $Version=1; Skin=new; Content-Length The length of the request body in octets (8-bit bytes) Content-Length: 348 Content-MD5 A Base64-encoded binary MD5 sum of the content of the request body Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ== Content-Type The MIME type of the body of the request (used with POST and PUT requests) Content-Type: application/x-www-form-urlencoded Date The date and time that the message was sent Date: Tue, 15 Nov 1994 08:12:31 GMT Authorization Authentication credentials for HTTP authentication oauth_token="ad180jjd733klru7" WWW-Authenticate: OAuth realm="http://sp.example.test/" Indicates the authentication scheme that should be used to access the requested entity WWW-Authenticate
  • 7. www.backand.com Response • The HTTP response is usually JSON • Status/Errors • CORS, JSONP
  • 8. www.backand.com Status/Errors HTTP Verb Specific Item (e.g. /car/{id}) Entire Collection (e.g. /car) 200 (OK), list of customers Use pagination, sorting and filtering to navigate big lists 200 (OK), single customer 404 (Not Found), if ID not found or invalid GET 404 (Not Found), unless you want to update/replace every resource in the entire collection 200 (OK) or 204 (No Content) 404 (Not Found), if ID not found or invalid PUT 201 (Created), 'Location' header with link to: /customers/{id} containing new ID POST 405 (Not Allowed) 404 (Not Found), unless you want to delete the whole collection—not often desirable 200 (OK) 404 (Not Found), if ID not found or invalid DELETE
  • 9. www.backand.com CORS, JSONP • CORS (cross-origin resource sharing) ‹ Recommended if no need to support older browser versions ‹ Server side only, by providing sets of headers supported by browsers ‹ Enables secure cloud services for organizations • JSONP ‹ Server and client side ‹ P stands for padding ‹ Pad the JSON with a function to overcome restrictions and remove it later
  • 10. Angular Key Services for REST www.backand.com • $http and $resource ‹ Ajax calls • $q ‹ Async progress
  • 11. $http and $resource • In this presentation we use $http • Key differences ‹ $resource provides additional abstraction level ‹ URI template ‹ Function names ‹ Parameters declaration www.backand.com • $resource example
  • 12. Angular Service with $resource List service (filter, sort, paging) Item service (CRUD) www.backand.com
  • 14. www.backand.com $q • Monitor asynchronous progress • Promise
  • 15. Prerequisite for the CRUD Demo www.backand.com • Angular • ng-grid • Backand REST API ‹ Gives you security, web hooks, business rules, hosting and logging ‹ Enables you to focus entirely on the client side
  • 16. ng-grid CRUD with REST www.backand.com • Authentication • Read • Create & Update • Delete
  • 17. www.backand.com Authentication • Get Oauth2 token • Add it to all the request headers • Using the $q promise
  • 18. www.backand.com CRUD - Read Prepare $http functions Authenticate then read and set the data into the controller scope
  • 19. CRUD – Create and Update Prepare $http functions In the ngGridEventEndCellEdit, prepare the JSON. If new row Create otherwise Update. www.backand.com
  • 20. www.backand.com CRUD – Delete Prepare $http functions Go through all the selected rows and delete them by ID
  • 21. www.backand.com Thank You! Github: https://www.backand.com/get-started Blog: http://blog.backand.com/ng-grid-real-rest/ Plunker: http://plnkr.co/edit/6jdCzZ?p=preview Directives: http://blog.backand.com/documentation Me: relly@backand.com

Notes de l'éditeur

  1. All REST APIs are similar by nature, not really a matter for the client My name is Relly and I am one of Backand’s founder and the VP R&D Backand allows you to choose a bootstrap template and connect a cloud (RDS) database to it. Backand provides the backend side, REST API, security and authentication, business rules and hosting Enable you to focus entirely in the client side To examine , you may use Backand demo DB or connect your own db – I will use Backand’s demo DB