learning-javascript
  • Introduction
  • JavaScript ES5 教學
    • 工具準備
    • 流程控制
    • JavaScript 基本特性, 變數
    • Function及Callback function
    • Array及JSON的操作
    • Object, Scope, this
    • ES5中的自訂物件類型-prototype
    • 進階-再講prototype
    • JavaScript重點整理
    • Closure
    • 多個JS檔, module, timer
    • 進階-module pattern
    • 其他
  • 實際應用
    • Server - HTTP request & response
    • Client - 用Fetch跟Server要資料
  • JavaScript ES6 教學
    • 箭頭函數Arrow Function
Powered by GitBook
On this page
  1. 實際應用

Server - HTTP request & response

Server回http response時粗略來分有兩種:

  1. Routing/Resource type (html, css, images),

  2. Restful/API type, e.g.{name:"apple"}.

Routing:

最簡單的web server: 
  收到 grimmer.io 這個http request, 回傳根目錄下的 /index.html 
  收到 grimmer.io/about.html, 回傳 /about.html
變化的:  
  收到 grimmer.io/about.html, 回傳 /assets/about.html (實際上的檔案位置)

Restful endpoint:

收到 grimmer.io/doc/doc1, 回傳doc1的內容,可以為XML, JSON等。 
通常是JSON, e.g. {author:"mike", content:"blahblah"}
Previous實際應用NextClient - 用Fetch跟Server要資料

Last updated 7 years ago