Get Started

Although QOR Admin is just a component of QOR but we believe that a visible UI could help you getting a sense of QOR easily. So let's set up a simple CMS by QOR Admin.

First, create a main.go with

package main

import (
  _ ""

// Define a GORM-backend model
type User struct {
  Name string

// Define another GORM-backend model
type Product struct {
  Name        string
  Description string

func main() {
  // Set up the database
  DB, _ := gorm.Open("sqlite3", "demo.db")
  DB.AutoMigrate(&User{}, &Product{})

  // Initalize
  Admin := admin.New(&admin.AdminConfig{DB: DB})

  // Create resources from GORM-backend model

  // Initalize an HTTP request multiplexer
  mux := http.NewServeMux()

  // Mount admin to the mux
  Admin.MountTo("/admin", mux)

  fmt.Println("Listening on: 9000")
  http.ListenAndServe(":9000", mux)

Now, execute go get -u ./... to install the dependencies, then run go run main.go and visit localhost:9000/admin to see the admin site.

Live Demo

Next Steps

Now you have a basic understanding of QOR Admin, you can dig it deeper in General Configuration or check other components of QOR.

results matching ""

    No results matching ""