文件名称:token-auth:nethttp的基于令牌的身份验证中间件
文件大小:8KB
文件格式:ZIP
更新时间:2024-05-24 12:09:00
Go
#token-auth Golang http中间件以实现基于令牌的身份验证 #用法 包装处理程序以使用大猩猩/多路复用器强制执行令牌验证 memStore := memstore . New ( "salty" ) r := mux . NewRouter () r . HandleFunc ( "/login/{id}" , func ( w http. ResponseWriter , req * http. Request ) { vars := mux . Vars ( req ) t := memStore . NewToken ( vars [ "id" ]) fmt . Fprintf ( w , "hi %s, your token is %s" , vars [ "id" ], t ) }) rRestrict := mux . NewRouter () s :
【文件预览】:
token-auth-master
----memory()
--------memorystore.go(2KB)
----auth.go(3KB)
----negroni()
--------middleware.go(818B)
----examples()
--------subroute()
--------handlefunc()
--------jwt()
----.gitignore(7B)
----README.md(2KB)
----jwt()
--------jwtstore.go(2KB)