Skip to content
Browse files

Adding docs for the code part of the QOR tutorial

  • Loading branch information...
Depado committed Feb 14, 2019
1 parent 037aac3 commit 98f033212bba36f7155486e96dd55ebed354a5dc
Showing with 26 additions and 0 deletions.
  1. +24 −0 code/qor/
  2. +2 −0 code/qor/admin/admin.go
@@ -0,0 +1,24 @@
# QOR Admin Example Code

This directory holds the code for the
["QOR Admin Tutorial"]( article.

Most of the useful code is located in the
[admin]( package.

- Declaring a QOR Admin easily with a simple constructor
- Bind to an existing gin router and specify a prefix for all the admin related
tasks (such as login, logout and admin interface itself)
- Initial migration and exported migration from the admin package to create the
`admin_users` table
- Manage admin users with a special setter for their password and
[bcrypt]( encryption in the
- Authentication handled by [Gin]( with
[gin-contrib/sessions]( and a cookie
- Separating admin-related structs (like admin user) and business structs (the
directory only has business structures)
- Simple login HTML template using
@@ -55,6 +55,8 @@ func New(db *gorm.DB, prefix, cookiesecret string) *Admin {
return &a

// Bind will bind the admin interface to an already existing gin router
// (*gin.Engine).
func (a Admin) Bind(r *gin.Engine) {
mux := http.NewServeMux()
a.adm.MountTo(a.adminpath, mux)

0 comments on commit 98f0332

Please sign in to comment.
You can’t perform that action at this time.