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

logo在线制作网站免费引流推广方法

logo在线制作网站,免费引流推广方法,c 做asp.net网站,修改wordpress访问路径【狂神说】Gin框架一小时上手 | 快速转型GoWeb开发 | Go语言零基础教程_哔哩哔哩_bilibili 1.介绍 2.简单程序 1)gin.GET/POST/PUT/DELETE函数 Go Gin 简明教程 | 快速入门 | 极客兔兔 (geektutu.com) 我的理解是:这类函数就像是在监听接口一样&…

【狂神说】Gin框架一小时上手 | 快速转型GoWeb开发 | Go语言零基础教程_哔哩哔哩_bilibili

1.介绍

2.简单程序

1)gin.GET/POST/PUT/DELETE函数

Go Gin 简明教程 | 快速入门 | 极客兔兔 (geektutu.com)

我的理解是:这类函数就像是在监听接口一样,执行后一直在等待,没有捕捉到对应参数就没任何影响,捕捉到了就调用其对应的执行函数。

2)gin.Context

代表上下文信息,是一个结构体,一般用来处理Http请求和响应

Gin源码分析系列之Context篇 - 知乎 (zhihu.com)

20210814学习牛逼的gin.Context - 知乎 (zhihu.com)

3)context.JSON

给前端响应一个JSON信息

4)ginServer.Use(favicon.New("./day.ico")) 

给页面标签加一个ico

5)restful api

6)http状态码

const (StatusContinue           = 100 // RFC 9110, 15.2.1StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2StatusProcessing         = 102 // RFC 2518, 10.1StatusEarlyHints         = 103 // RFC 8297StatusOK                   = 200 // RFC 9110, 15.3.1StatusCreated              = 201 // RFC 9110, 15.3.2StatusAccepted             = 202 // RFC 9110, 15.3.3StatusNonAuthoritativeInfo = 203 // RFC 9110, 15.3.4StatusNoContent            = 204 // RFC 9110, 15.3.5StatusResetContent         = 205 // RFC 9110, 15.3.6StatusPartialContent       = 206 // RFC 9110, 15.3.7StatusMultiStatus          = 207 // RFC 4918, 11.1StatusAlreadyReported      = 208 // RFC 5842, 7.1StatusIMUsed               = 226 // RFC 3229, 10.4.1StatusMultipleChoices   = 300 // RFC 9110, 15.4.1StatusMovedPermanently  = 301 // RFC 9110, 15.4.2StatusFound             = 302 // RFC 9110, 15.4.3StatusSeeOther          = 303 // RFC 9110, 15.4.4StatusNotModified       = 304 // RFC 9110, 15.4.5StatusUseProxy          = 305 // RFC 9110, 15.4.6_                       = 306 // RFC 9110, 15.4.7 (Unused)StatusTemporaryRedirect = 307 // RFC 9110, 15.4.8StatusPermanentRedirect = 308 // RFC 9110, 15.4.9StatusBadRequest                   = 400 // RFC 9110, 15.5.1StatusUnauthorized                 = 401 // RFC 9110, 15.5.2StatusPaymentRequired              = 402 // RFC 9110, 15.5.3StatusForbidden                    = 403 // RFC 9110, 15.5.4StatusNotFound                     = 404 // RFC 9110, 15.5.5StatusMethodNotAllowed             = 405 // RFC 9110, 15.5.6StatusNotAcceptable                = 406 // RFC 9110, 15.5.7StatusProxyAuthRequired            = 407 // RFC 9110, 15.5.8StatusRequestTimeout               = 408 // RFC 9110, 15.5.9StatusConflict                     = 409 // RFC 9110, 15.5.10StatusGone                         = 410 // RFC 9110, 15.5.11StatusLengthRequired               = 411 // RFC 9110, 15.5.12StatusPreconditionFailed           = 412 // RFC 9110, 15.5.13StatusRequestEntityTooLarge        = 413 // RFC 9110, 15.5.14StatusRequestURITooLong            = 414 // RFC 9110, 15.5.15StatusUnsupportedMediaType         = 415 // RFC 9110, 15.5.16StatusRequestedRangeNotSatisfiable = 416 // RFC 9110, 15.5.17StatusExpectationFailed            = 417 // RFC 9110, 15.5.18StatusTeapot                       = 418 // RFC 9110, 15.5.19 (Unused)StatusMisdirectedRequest           = 421 // RFC 9110, 15.5.20StatusUnprocessableEntity          = 422 // RFC 9110, 15.5.21StatusLocked                       = 423 // RFC 4918, 11.3StatusFailedDependency             = 424 // RFC 4918, 11.4StatusTooEarly                     = 425 // RFC 8470, 5.2.StatusUpgradeRequired              = 426 // RFC 9110, 15.5.22StatusPreconditionRequired         = 428 // RFC 6585, 3StatusTooManyRequests              = 429 // RFC 6585, 4StatusRequestHeaderFieldsTooLarge  = 431 // RFC 6585, 5StatusUnavailableForLegalReasons   = 451 // RFC 7725, 3StatusInternalServerError           = 500 // RFC 9110, 15.6.1StatusNotImplemented                = 501 // RFC 9110, 15.6.2StatusBadGateway                    = 502 // RFC 9110, 15.6.3StatusServiceUnavailable            = 503 // RFC 9110, 15.6.4StatusGatewayTimeout                = 504 // RFC 9110, 15.6.5StatusHTTPVersionNotSupported       = 505 // RFC 9110, 15.6.6StatusVariantAlsoNegotiates         = 506 // RFC 2295, 8.1StatusInsufficientStorage           = 507 // RFC 4918, 11.5StatusLoopDetected                  = 508 // RFC 5842, 7.2StatusNotExtended                   = 510 // RFC 2774, 7StatusNetworkAuthenticationRequired = 511 // RFC 6585, 6
)

3.给前端响应

发送请求和响应

给前端发送json和页面(静态资源)

package mainimport ("net/http""github.com/gin-gonic/gin""github.com/thinkerou/favicon"
)func main() {//·1.创建一个服务ginServer := gin.Default()ginServer.Use(favicon.New("./day.ico")) //加网站小icon//连接数据库之类,之后可以作为一个接口就可以给前端返回数据// //2.访问地址,处理我们的请求Request Response// //发送一个GET请求,如果url有hello,会执行后面的函数给前端返回信息// ginServer.GET("/hello", func(context *gin.Context) {// 	context.JSON(200, gin.H{"msg": "helloworld"})// })// ginServer.POST("/user", func(c *gin.Context) {// 	//返回json数据,状态码200就是http.StatusOK// 	c.JSON(200, gin.H{"msg": "post,user"})// })// ginServer.PUT("/user")// ginServer.DELETE("/user")//3.响应页面给前端//加载静态页面ginServer.LoadHTMLGlob("templates/*")//ginServer.LoadHTMLFiles("templates/index.html") //加载单个//4.加载资源文件(资源文件位置,根目录位置)ginServer.Static("/static", "./static")ginServer.GET("/index", func(c *gin.Context) {//返回页面c.HTML(http.StatusOK, "index.html", gin.H{"msg": "这是go后台传递来的数据...",})})//服务器端口,给一个服务端口,默认8080ginServer.Run(":8080") //一定有个冒号
}

4.获取请求中的参数

1)前端表单

package mainimport ("encoding/json""net/http""github.com/gin-gonic/gin""github.com/thinkerou/favicon"
)/*
固定格式:请求,处理请求函数
ginServer.POST("/user", func(c *gin.Context) {
})
*/
func main() {//·1.创建一个服务ginServer := gin.Default()ginServer.Use(favicon.New("./day.ico")) //加网站小icon//连接数据库之类,之后可以作为一个接口就可以给前端返回数据//3.响应页面给前端//加载静态页面ginServer.LoadHTMLGlob("templates/*")//ginServer.LoadHTMLFiles("templates/index.html") //加载单个//4.加载资源文件(资源文件位置,根目录位置)ginServer.Static("/static", "./static")ginServer.GET("/index", func(c *gin.Context) {//返回页面c.HTML(http.StatusOK, "index.html", gin.H{"msg": "这是go后台传递来的数据...",})})//7.获取前端表单数据ginServer.POST("/user/add", func(c *gin.Context) {//拿到数据username := c.PostForm("username")password := c.PostForm("password")//数据校验// if username == {// }//给前端返回数据c.JSON(http.StatusOK, gin.H{"msg":      "Ok","password": password,"username": username,})})//服务器端口,给一个服务端口,默认8080ginServer.Run(":8080") //一定有个冒号
}

 2)前端给后端传json

package mainimport ("encoding/json""net/http""github.com/gin-gonic/gin""github.com/thinkerou/favicon"
)/*
固定格式:请求,处理请求函数
ginServer.POST("/user", func(c *gin.Context) {
})
*/
func main() {//·1.创建一个服务ginServer := gin.Default()ginServer.Use(favicon.New("./day.ico")) //加网站小icon//前端给后端传jsonginServer.POST("/json", func(c *gin.Context) {//request.bodydata, _ := c.GetRawData()  //从请求体获取数据var m map[string]interface{}_ = json.Unmarshal(data, &m) //解析后端接收的json//给前端发送回去c.JSON(http.StatusOK,m)})//服务器端口,给一个服务端口,默认8080ginServer.Run(":8080") //一定有个冒号
}

3)?&传参

package mainimport ("net/http""github.com/gin-gonic/gin""github.com/thinkerou/favicon"
)/*
固定格式:请求,处理请求函数
ginServer.POST("/user", func(c *gin.Context) {
})
*/
func main() {//·1.创建一个服务ginServer := gin.Default()ginServer.Use(favicon.New("./day.ico")) //加网站小icon//?传参// url输入 /user/info?userid=xxx&username=kuangshenginServer.GET("/user/info", func(c *gin.Context) {userid := c.Query("userid") //接收前端问号传参的值username := c.Query("username")//返回json数据,状态码200就是http.StatusOKc.JSON(http.StatusOK, gin.H{"userid":   userid,"username": username,})})//服务器端口,给一个服务端口,默认8080ginServer.Run(":8080") //一定有个冒号
}

4)RESTful风格传参

package mainimport ("net/http""github.com/gin-gonic/gin""github.com/thinkerou/favicon"
)/*
固定格式:请求,处理请求函数
ginServer.POST("/user", func(c *gin.Context) {
})
*/
func main() {//·1.创建一个服务ginServer := gin.Default()ginServer.Use(favicon.New("./day.ico")) //加网站小icon//RESTful风格传参,冒号后自动接收参数//url输入 /user/info/1/ kuangshenginServer.GET("/user/info/:userid/:username", func(c *gin.Context) {userid := c.Param("userid")username := c.Param("username")//返回json数据,状态码200就是http.StatusOKc.JSON(http.StatusOK, gin.H{"userid":   userid,"username": username,})})//服务器端口,给一个服务端口,默认8080ginServer.Run(":8080") //一定有个冒号
}

5.路由,重定向

1)普通路由

该案例自动跳转必应

// 路由
func route(ginServer *gin.Engine) {ginServer.GET("test", func(context *gin.Context) {//重定向状态301context.Redirect(http.StatusMovedPermanently, "https://www.bing.com")})
}

2).404

只要输入的访问路径不被已知的请求处理,那么就是404状态,会被该请求捕获并跳转到404.

404页面需要提前加载一下静态资源

// 404页面
func noRoute(ginServer *gin.Engine) {ginServer.NoRoute(func(context *gin.Context) {context.HTML(http.StatusNotFound, "404.html", nil) //会从指定的静态资源路径下去找})

3)路由组

对一个路径下的不同分路径请求进行处理

// 路由组,相当于对一个路径下不同分路径一起做处理
func routeGroup(ginServer *gin.Engine) {userGroup := ginServer.Group("/user"){userGroup.GET("/add")userGroup.GET("/login")userGroup.GET("/logout")}orderGroup := ginServer.Group("/order"){orderGroup.GET("/add")orderGroup.GET("/delete")}}

6.拦截器

1)自定义中间件

流程:定义,注册,指定(可有可无)

注册中间件之后默认给所有请求使用,如果在某个请求里指定了,就只给这一个请求使用。

package mainimport ("encoding/json""log""net/http""github.com/gin-gonic/gin""github.com/thinkerou/favicon"
)// 自定义go中间件拦截器
func myHandler() gin.HandlerFunc {return func(context *gin.Context) {//自定义中间件设置的值,在后续处理只要调用了这个中间件的都可以拿到这里的参数context.Set("usersession", "userid-1")if true { //放行context.Next()} else { //阻止context.Abort()}}
}// 使用自定义中间件
func handler(ginServer *gin.Engine) {//这样请求被方法接收之前会先被中间件拦截处理,如果通过,才会被方法接收处理//?传参// url输入 /user/info2?userid=xxx&username=kuangshenginServer.GET("/user/info2",myHandler(), func(c *gin.Context) {//取出中间件的值usersession := c.MustGet("usersession").(string)log.Println(usersession)    //后台打印userid := c.Query("userid") //接收前端问号传参的值username := c.Query("username")c.JSON(http.StatusOK, gin.H{"userid":   userid,"username": username,})})
}func main() {//·1.创建一个服务ginServer := gin.Default()//注册中间件ginServer.Use(myHandler())ginServer.Use(favicon.New("./day.ico")) //加网站小icon//连接数据库之类,之后可以作为一个接口就可以给前端返回数据//使用自定义中间件handler(ginServer)//服务器端口,给一个服务端口,默认8080ginServer.Run(":8080") //一定有个冒号
}


文章转载自:
http://dinncopermissive.stkw.cn
http://dinncozwitterion.stkw.cn
http://dinncobake.stkw.cn
http://dinncohalocarbon.stkw.cn
http://dinncomayst.stkw.cn
http://dinncosphenoid.stkw.cn
http://dinncogyniatrics.stkw.cn
http://dinncobors.stkw.cn
http://dinncoossifrage.stkw.cn
http://dinncotrite.stkw.cn
http://dinnconudicaul.stkw.cn
http://dinncoveridical.stkw.cn
http://dinncoformat.stkw.cn
http://dinncowhereof.stkw.cn
http://dinncoconvoy.stkw.cn
http://dinncopleiad.stkw.cn
http://dinncosuperinduce.stkw.cn
http://dinncotoluidide.stkw.cn
http://dinncoantimonsoon.stkw.cn
http://dinncohypoesthesia.stkw.cn
http://dinncoblastocoel.stkw.cn
http://dinncovernalization.stkw.cn
http://dinncoelaboration.stkw.cn
http://dinncofirmness.stkw.cn
http://dinncohesperinos.stkw.cn
http://dinncosnockered.stkw.cn
http://dinncomirabilis.stkw.cn
http://dinncogallooned.stkw.cn
http://dinncobootlace.stkw.cn
http://dinncorebuttal.stkw.cn
http://dinncoger.stkw.cn
http://dinncodiscohere.stkw.cn
http://dinncounaccomplished.stkw.cn
http://dinncoperioeci.stkw.cn
http://dinnconodulus.stkw.cn
http://dinncoimmoderation.stkw.cn
http://dinncounsurpassable.stkw.cn
http://dinncoaffecting.stkw.cn
http://dinncoadiaphoresis.stkw.cn
http://dinncolipogram.stkw.cn
http://dinncoexpedition.stkw.cn
http://dinncoretranslate.stkw.cn
http://dinncodoven.stkw.cn
http://dinncofixity.stkw.cn
http://dinncocystic.stkw.cn
http://dinncoirradiancy.stkw.cn
http://dinncomorassy.stkw.cn
http://dinncophenolic.stkw.cn
http://dinncoappendectomy.stkw.cn
http://dinncosonsy.stkw.cn
http://dinncolandside.stkw.cn
http://dinncoarafura.stkw.cn
http://dinncodeformative.stkw.cn
http://dinncoindubitably.stkw.cn
http://dinncospeakeress.stkw.cn
http://dinncoplastogamy.stkw.cn
http://dinncopredicament.stkw.cn
http://dinncocalycular.stkw.cn
http://dinncokingship.stkw.cn
http://dinncocovalency.stkw.cn
http://dinnconz.stkw.cn
http://dinncononcombustibility.stkw.cn
http://dinncoazinphosmethyl.stkw.cn
http://dinncoretroversion.stkw.cn
http://dinncodemonetise.stkw.cn
http://dinncodowel.stkw.cn
http://dinncogrumbler.stkw.cn
http://dinncoprecompression.stkw.cn
http://dinncoelbowboard.stkw.cn
http://dinncoeurobond.stkw.cn
http://dinncosquash.stkw.cn
http://dinncoconfiscator.stkw.cn
http://dinncomarvel.stkw.cn
http://dinncocertes.stkw.cn
http://dinncosutlej.stkw.cn
http://dinncograndmamma.stkw.cn
http://dinncoespanol.stkw.cn
http://dinncoraucity.stkw.cn
http://dinncotrisodium.stkw.cn
http://dinncoservia.stkw.cn
http://dinncoretire.stkw.cn
http://dinncoinclip.stkw.cn
http://dinncoscollop.stkw.cn
http://dinncoliverwort.stkw.cn
http://dinncostuffing.stkw.cn
http://dinncormt.stkw.cn
http://dinncohosteler.stkw.cn
http://dinncoshod.stkw.cn
http://dinncointerplanetary.stkw.cn
http://dinncostramonium.stkw.cn
http://dinncoinsemination.stkw.cn
http://dinncobetenoire.stkw.cn
http://dinncosaturate.stkw.cn
http://dinncocynical.stkw.cn
http://dinncoinlayer.stkw.cn
http://dinncotemplar.stkw.cn
http://dinncobeaufort.stkw.cn
http://dinncoaerarium.stkw.cn
http://dinncodarch.stkw.cn
http://dinncohagiolatrous.stkw.cn
http://www.dinnco.com/news/146080.html

相关文章:

  • 什么建站平台好谷歌广告代理
  • 如何做一个购物网站页面合肥网站建设公司
  • 泉州哪个公司网站做的好优化师培训
  • 游戏建模师工资一般多少响应式网站 乐云seo品牌
  • 微信小程序网站建设公司厦门人才网招聘
  • 中国制造网建站爱站网的关键词是怎么来的
  • 男男sm怎么做视频网站百度搜索网址
  • wordpress建站案例视频教程营销推广方案ppt案例
  • 重庆梁平网站建设报价新乡网站优化公司推荐
  • 网站设计流程详细步骤新闻头条今日要闻最新
  • 网站建设项目说明书模板一键生成网站
  • 太仓做网站的公司百度权重高的发帖网站
  • 库尔勒网站建设官方百度app下载安装
  • 博物馆网站做的好的搜索引擎营销的作用
  • 为什么淘宝店主不自己做电商网站线上营销策划案例
  • 武汉做营销型网站推广百度怎样发布信息
  • 国外h5建站百度推广seo自学
  • 网架加工厂家seo培训公司
  • 珠海品牌网站建设查看别人网站的访问量
  • 19年做网站外贸建站推广公司
  • 三亚市住房和城乡建设局网站优化排名优化
  • wordpress需要备案号网络推广优化网站
  • 网站开发实例社区收录提交入口
  • 门户网站怎么做优化推广赚佣金的平台
  • 深圳住建局官网seo黑帽技术有哪些
  • 网站建设属于什么支出网络营销包括几个部分
  • 广州网站开发债券交百度竞价推广运营
  • 西安网站建设公seo是指什么
  • 动漫网站设计方案今天百度数据
  • 网站上面带官网字样怎么做的在百度上怎么注册网站