본문 바로가기

대외활동/UMC

[UMC 2기] Android 파트 9주차 정리

복습 및 정리

Client, Server의 관계

Client  →  Server (Request)

Client  ←  Server (Response

 

HTTP 통신 (Https)

HyperText Transfer Protocol (HTTP) is an application-layer protocol for transmitting hypermedia documents, such as HTML. It was designed for communication between web browsers and web servers, but it can also be used for other purposes. HTTP follows a classical client-server model, with a client opening a connection to make a request, then waiting until it receives a response. HTTP is a stateless protocol, meaning that the server does not keep any data (state) between two requests.

 

HyperText Transfer Protocol Secure (HTTPS)는 HTTP의 안전한 버전!

 

API, Restful API

An Application Programming Interface(API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software.

RestAPI

Rest(Representational State Transfer) 아키텍처의 제약 조건을 준수하는 API를 뜻한다.

HTTP URI(Uniform Resource Identifier)를 통해 자원(Resource)을 명시하고, HTTP Method (POST, GET, PUT, DELETE, …)를 통해 해당 자원에 대한 CRUD Operation을 적용하는 것을 의미한다.

‘REST’한 API를 ‘RESTful API’라고 한다.

URL vs URI

URL(Uniform Resource Locator) : 자원이 실제로 존재하는 위치

URI(Uniform Resource Identifier) : 자원의 위치뿐만 아니라 자원에 대한 고유 식별자

URI가 URL의 상위 개념

ex)

https://example.com → URL이면서 URI

https://example.com/skin → URL이면서 URI

https://example.com/123 → URI이지만 URL X

https://example.com/one?id=123 → URI이지만 URL X, https://example.com/one까지가 URL

→ 식별자가 포함되어 있으면 URL이라고 부르지 않음, 식별자 전까지가 URL

 

Retrofit

안드로이드에서 서버와 클라이언트 간 http 통신을 위한 라이브러리

ex) 실습

1. AuthRetrofitInterface라는 interface파일을 만들고 함수 정의

2. NetworkModule 파일에 getRetrofit() 정의

3. AuthService파일에 모듈화

 

참조

https://darvishdarab.github.io/cs421_f20/docs/readings/restful/api/

https://developer.mozilla.org/en-US/docs/Web/HTTP

https://velog.io/@torang/URL%EA%B3%BC-URI%EC%9D%98-%EC%B0%A8%EC%9D%B4%EC%A0%90

https://medium.com/@js230023/url-%EA%B3%BC-uri%EC%9D%98-%EC%B0%A8%EC%9D%B4-154d70814d2a

https://square.github.io/retrofit/