How to set HTTP status code on http.ResponseWriter

后端 未结 3 1204
隐瞒了意图╮
隐瞒了意图╮ 2021-01-30 19:28

How do I set the HTTP status code on an http.ResponseWriter (e.g. to 500 or 403)?

I can see that requests normally have a status code of 200 attached to the

3条回答
  •  甜味超标
    2021-01-30 19:42

    w.WriteHeader(http.StatusInternalServerError)
    w.WriteHeader(http.StatusForbidden)
    

    full list here

提交回复
热议问题