A demo with Hertz
and Session
, this demo aims to demonstrate a distributed session solution based on the hertz-contrib/sessions
.
The distributed session solution based on redis is to store the sessions of different servers in redis or redis cluster, which aims to solve the problem that the sessions of multiple servers are not synchronized in the case of distributed system.
- Use
thrift
IDL to defineHTTP
interface - Use
hz
to generate code - Use
hertz-contrib/sessions
to store sessions - Use
hertz-contrib/csrf
to prevent Cross-Site Request Forgery attacks - Use
Gorm
andMySQL
- Use
AdminLTE
as frontend page
Use Hertz's sessions extension, refer to hertz-contrib/sessions
Use Hertz's csrf extension, refer to hertz-contrib/csrf
This demo use thrift
IDL to define HTTP
interface. The specific interface define in user.thrift
This demo use hz
to generate code. The use of hz
refers to hz
The hz
commands used can be found in Makefile
The use of binding and Validate refers to Binding and Validate
This demo use Gorm
to operate MySQL
and refers to Gorm
This demo captures the AdminLTE login and registration page as the front-end page.
cd bizdemo/hertz_session && docker-compose up
cd bizdemo/hertz_session
go run .
- Registration Page
- Login Page
- Index Page