当前位置: 首页 > news >正文

什么2007做视频网站游戏网站排行榜前十名

什么2007做视频网站,游戏网站排行榜前十名,江苏常州网站建设公司,设计工作室 网站学习记录 1 集成 Gorilla Mux1.1 为什么不选择 HttpRouter#xff1f;1.2 安装 gorilla/mux1.3 使用 gorilla/mux1.4 迁移到 Gorilla Mux1.4.1 新增 homeHandler1.4.2 指定 Methods () 来区分请求方法1.4.3 请求路径参数和正则匹配1.4.4 命名路由与链接生成 1 集成 Gorilla Mu… 学习记录 1 集成 Gorilla Mux1.1 为什么不选择 HttpRouter1.2 安装 gorilla/mux1.3 使用 gorilla/mux1.4 迁移到 Gorilla Mux1.4.1 新增 homeHandler1.4.2 指定 Methods () 来区分请求方法1.4.3 请求路径参数和正则匹配1.4.4 命名路由与链接生成 1 集成 Gorilla Mux 1.1 为什么不选择 HttpRouter HttpRouter是目前最快的路由器被知名GIN框架所采用。 没有选择HttpRouter是因为功能略显单一没有由于命名功能。 HttpRouter和GIN比较适合性能要求高路由功能相对简单的项目中如API或微服务。在全站开发Web中gorilla/mux功能更强大比较实用。 1.2 安装 gorilla/mux 安装第三方依赖 go get -u github.com/gorilla/mux查看文件变更情况 git status两个文件变更 1.3 使用 gorilla/mux 1.4 迁移到 Gorilla Mux 改进main.go package mainimport (fmtnet/httpgithub.com/gorilla/mux )func homeHandler(w http.ResponseWriter, r *http.Request) {w.Header().Set(Content-Type, text/html; charsetutf-8)fmt.Fprint(w, h1Hello, 欢迎来到 goblog/h1) }func aboutHandler(w http.ResponseWriter, r *http.Request) {w.Header().Set(Content-Type, text/html; charsetutf-8)fmt.Fprint(w, 此博客是用以记录编程笔记如您有反馈或建议请联系 a href\mailto:summerexample.com\summerexample.com/a) }func notFoundHandler(w http.ResponseWriter, r *http.Request) {w.Header().Set(Content-Type, text/html; charsetutf-8)w.WriteHeader(http.StatusNotFound)fmt.Fprint(w, h1请求页面未找到 :(/h1p如有疑惑请联系我们。/p) }func articlesShowHandler(w http.ResponseWriter, r *http.Request) {vars : mux.Vars(r)id : vars[id]fmt.Fprint(w, 文章 IDid) }func articlesIndexHandler(w http.ResponseWriter, r *http.Request) {fmt.Fprint(w, 访问文章列表) }func articlesStoreHandler(w http.ResponseWriter, r *http.Request) {fmt.Fprint(w, 创建新的文章) }func main() {router : mux.NewRouter()router.HandleFunc(/, homeHandler).Methods(GET).Name(home)router.HandleFunc(/about, aboutHandler).Methods(GET).Name(about)router.HandleFunc(/articles/{id:[0-9]}, articlesShowHandler).Methods(GET).Name(articles.show)router.HandleFunc(/articles, articlesIndexHandler).Methods(GET).Name(articles.index)router.HandleFunc(/articles, articlesStoreHandler).Methods(POST).Name(articles.store)// 自定义 404 页面router.NotFoundHandler http.HandlerFunc(notFoundHandler)// 通过命名路由获取 URL 示例homeURL, _ : router.Get(home).URL()fmt.Println(homeURL: , homeURL)articleURL, _ : router.Get(articles.show).URL(id, 23)fmt.Println(articleURL: , articleURL)http.ListenAndServe(:3000, router) }1.4.1 新增 homeHandler 首先因为使用的是精确匹配我们将 defaultHandler 变更 homeHandler 且将处理 404 的代码移除。 1.4.2 指定 Methods () 来区分请求方法 curl测试 curl http://localhost:3000/articlescurl -Method POST http://localhost:3000/articles注意 在 Gorilla Mux 中如未指定请求方法默认会匹配所有方法。 1.4.3 请求路径参数和正则匹配 router.HandleFunc(/articles/{id:[0-9]}, articlesShowHandler).Methods(GET).Name(articles.show)Handler 中获取到这个参数: func articlesShowHandler(w http.ResponseWriter, r *http.Request) {vars : mux.Vars(r)id : vars[id]fmt.Fprint(w, 文章 IDid) }1.4.4 命名路由与链接生成 air中显示打印结果
http://www.hkea.cn/news/14342251/

相关文章:

  • 如何查询网站被百度收录情况厦门有没网站建设的公司
  • 做网站要注册商标第几类wordpress 2015主题公园
  • angular做的网站深圳微商城网站设计制作
  • 品牌网站建设十小蝌蚪网站需要做404页面吗
  • 天津企商网站建设公司wordpress房产主题汉化版
  • 济南专业网站制作网站建设方案书阿里云模板
  • 公司建设网站价格做网站运营工资多少
  • wordpress建哪些网站装修图片大全
  • 常青花园做网站的公司在哪个网站找学做包子
  • 了解网站建设管理基于iview的网站开发模板
  • 随州网站建设有哪些企业crm系统
  • 谈谈网站建设创新问题企业网站建设的基本流程
  • 哪些网站可以做移动端模板wordpress yii
  • 十八个免费的舆情网站鞍山新款网站制作哪家好
  • 室内设计网站配色appvs2008 网站消息弹窗怎么做
  • 制作小程序网站源码网站开发效率
  • 医院做网站定位上海建设网站定做
  • 万网注册的域名怎么建设网站如何做网站广告
  • 江西建设厅网站官网5g创业网站建设
  • wordpress付费插件网站中国互联网协会发起者包括
  • 哪里有好网站设计如何注册网站主办者
  • 做网站备案完成之后需要干什么wordpress主题安装不成功
  • 电商网站开发公司哪家好营销qq怎么申请
  • 网站版面布局结构图河间做网站
  • 微信小程序 网站开发幸运28网站代理怎么做
  • 外国网站 icp备案做网站放到百度上需要什么
  • 网站推广托管公司产品互联网营销推广
  • 长沙企业网站建设哪家好广州新际网站建设
  • 门头沟网站开发婚纱摄影网站建设大概多少钱
  • 免费购物的软件郑州网站制作专业乐云seo