Frontend-Vuejs

Vuejs ctx methods (ctx.params, ctx.reqeust.body, ctx.response.status, ...)

jiwoolee 2021. 8. 5. 15:49

ctx.params / ctx.reqeust.body / ctx.response.status / ...

ctx 관련하여 http ctx 메소드 확인

 

 

 

 

ctx.params

ctx.params 
// URL params, :name

 

 

ctx.request.body

ctx.request.body 
// POST params

 

 

ctx.query

ctx.query 
//ctx.request.query 대신 ctx.query로 가능 - koa
// URL params, ?name=jw

 

 

 

ctx.response.status

ctx.response.status
//숫자 코드로 응답 상태 설정

숫자별 상태 의미

더보기
  • 100 "continue"
  • 101 "switching protocols"
  • 102 "processing"
  • 200 "ok"
  • 201 "created"
  • 202 "accepted"
  • 203 "non-authoritative information"
  • 204 "no content"
  • 205 "reset content"
  • 206 "partial content"
  • 207 "multi-status"
  • 208 "already reported"
  • 226 "im used"
  • 300 "multiple choices"
  • 301 "moved permanently"
  • 302 "found"
  • 303 "see other"
  • 304 "not modified"
  • 305 "use proxy"
  • 307 "temporary redirect"
  • 308 "permanent redirect"
  • 400 "bad request"
  • 401 "unauthorized"
  • 402 "payment required"
  • 403 "forbidden"
  • 404 "not found"
  • 405 "method not allowed"
  • 406 "not acceptable"
  • 407 "proxy authentication required"
  • 408 "request timeout"
  • 409 "conflict"
  • 410 "gone"
  • 411 "length required"
  • 412 "precondition failed"
  • 413 "payload too large"
  • 414 "uri too long"
  • 415 "unsupported media type"
  • 416 "range not satisfiable"
  • 417 "expectation failed"
  • 418 "I'm a teapot"
  • 422 "unprocessable entity"
  • 423 "locked"
  • 424 "failed dependency"
  • 426 "upgrade required"
  • 428 "precondition required"
  • 429 "too many requests"
  • 431 "request header fields too large"
  • 500 "internal server error"
  • 501 "not implemented"
  • 502 "bad gateway"
  • 503 "service unavailable"
  • 504 "gateway timeout"
  • 505 "http version not supported"
  • 506 "variant also negotiates"
  • 507 "insufficient storage"
  • 508 "loop detected"
  • 510 "not extended"
  • 511 "network authentication required"

 

 

 

https://runebook.dev/en/docs/koa/api/response.md

 

 

ctx.request.header
ctx.request.header: Set request header object.

 

ctx.request.method
ctx.request.method: Set request method, useful for implementing middleware

**

미들웨어:

 route를 변경할때 걸러주었으면 하는 역할, 예외처리를 해야하는 것, 페이지 접속시마다 특정 기능이 실행되었으면 하는 기능을 모두 처리

 

 

 

ctx.request.path
ctx.request.path: Set request pathname and retain query-string when present.

 

 

 

 

 

 

 

 


더 다양한 http ctx 메소드

 

https://runebook.dev/en/docs/koa/api/request.md

 

Koa - Request - A Koa Request object is an abstraction on top of node's vanilla request object,

Request A Koa Request object is an abstraction on top of node's vanilla request object, providing additional functionality that is useful for every day HTTP server development. API Request header object. This is the same as the headers field on node's http

runebook.dev