16
Radenko Zec Lanaco d.o.o ASP.NET Web API do maksimuma October 23 rd 2013

Sinergija2013 ASP.NET Web API to the max

Embed Size (px)

Citation preview

Page 1: Sinergija2013 ASP.NET Web API to the max

Radenko ZecLanaco d.o.o

ASP.NET Web API do maksimuma

October 23rd 2013

Page 2: Sinergija2013 ASP.NET Web API to the max

O čemu pričamo i ne pričamo danas

• ASP.NET Web API v1

• ASP.NET Web API v2

• Attribute routing

• Owin self host (Katana)

• IHttpActionResult

• OData improvements...

Page 3: Sinergija2013 ASP.NET Web API to the max

Da li je ASP.NET Web API = RESTful service?

ASP.NET Web API ne diktira stil arhitekture

ali vi možete da razvijete RESTful service pomoću ASP.NET Web API- ja

Page 4: Sinergija2013 ASP.NET Web API to the max
Page 5: Sinergija2013 ASP.NET Web API to the max

ASP.NET Web API Web sajtoviMobilni i tablet

uređaji

Web API

Baza

Drugi tipovi aplikacija

Page 6: Sinergija2013 ASP.NET Web API to the max

Richardson-ov model zrelosti REST-a

Page 7: Sinergija2013 ASP.NET Web API to the max

Rast Web API-ja

Page 8: Sinergija2013 ASP.NET Web API to the max

Koje metode podržava Web API ?

Metod Akcija HTTPMetod Relativni URI

Get Vraća listu svih kontakata

GET /api/contacts

Get Vraća kontakt na osnovu id-a

GET /api/contacts/id

Add Dodaje novi kontakt POST /api/contacts

Update Mijenja selektovani kontakt

PUT /api/contacts

Delete Briše kontakt DELETE /api/contacts/id

Page 9: Sinergija2013 ASP.NET Web API to the max

Kako napraviti Web API?

public class PersonController : ApiController{

List<Person> _people;public PersonController(){

_people = new List<Person>();_people.AddRange(new Person[]{

new Person { Id = 1, Name = "Chuck Norris" },new Person { Id = 2, Name = "David Carradine" },new Person { Id = 3, Name = "Bruce Lee" }

});

Page 10: Sinergija2013 ASP.NET Web API to the max

Kako napraviti Web API?// GET /api/personpublic IEnumerable<Person> Get(){

return _people;}

// GET /api/person/5public Person Get(int id){

return _people.First(x => x.Id == id);}

Page 11: Sinergija2013 ASP.NET Web API to the max

Rutiranje Web API-ja public static void RegisterRoutes(RouteCollection routes){

routes.MapHttpRoute(name: "DefaultApi",routeTemplate: "api/{controller}/{id}",defaults: new { id = RouteParameter.Optional }

);}

Page 12: Sinergija2013 ASP.NET Web API to the max

Hosting i arhitektura

Page 13: Sinergija2013 ASP.NET Web API to the max

SilverReader

• Ultra brz Web API

• Korišten ASP.NET Web API v1

Page 14: Sinergija2013 ASP.NET Web API to the max

DEMO

Page 15: Sinergija2013 ASP.NET Web API to the max

Optimizacije

• Westwind serijalizer

• GZIP kompresija

Page 16: Sinergija2013 ASP.NET Web API to the max

Hvala na pažnji