1 Star 0 Fork 0

pku-min-java/min-browser-http

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
handlerHelper.go 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
ghy 提交于 2021-06-17 22:25 +08:00 . add: request parsing
/*
* @Author: hongyu guo
* @Description:
* @Version: 1.0.0
* @Date: 15:56 2021/06/17
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
*/
package minhttp
import "fmt"
// Error replies to the request with the specified error message and HTTP code.
// It does not otherwise end the request; the caller should ensure no further
// writes are done to w.
// The error message should be plain text.
func Error(w ResponseWriter, error string, code int) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Header().Set("X-Content-Type-Options", "nosniff")
w.WriteHeader(code)
fmt.Fprintln(w, error)
}
// NotFound replies to the request with an HTTP 404 not found error.
func NotFound(w ResponseWriter, r *Request) { Error(w, "404 page not found", StatusNotFound) }
// NotFoundHandler returns a simple request handler
// that replies to each request with a ``404 page not found'' reply.
func NotFoundHandler() Handler { return HandlerFunc(NotFound) }
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/pku-min-java/min-browser-http.git
git@gitee.com:pku-min-java/min-browser-http.git
pku-min-java
min-browser-http
min-browser-http
master

搜索帮助