gorf

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 4 Imported by: 6

README

gorf

Go

Django inspired Golang Rest Framework

Installation

Install gorf

go get github.com/go-gorf/gorf

Install gorf auth app

go get github.com/go-gorf/contrib/auth

Quickstart

Firstly, Create a new main package with following code

package main

import (
	"log"

	"github.com/go-gorf/gorf"
	"github.com/go-gorf/gorf-contrib/auth"
)

func main() {
	r := BootstrapRouter()
	user := auth.User{}
	println(user.Email)
	err := r.Run()
	if err != nil {
		log.Fatal("Unable to create the gin server")
	} // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}

Next, Create a settings.go file in the main package with the following code snippet

package main

import (
	"github.com/gin-gonic/gin"
	"github.com/go-gorf/gorf"
	"github.com/go-gorf/gorf-contrib/auth"
)

// add all the apps
var apps = []gorf.GorfApp{
	&auth.AuthApp,
}

func LoadSettings() {
	// jwt secret key
	gorf.Settings.SecretKey = "GOo8Rs8ht7qdxv6uUAjkQuopRGnql2zWJu08YleBx6pEv0cQ09a"
}

// bootstrap server
func BootstrapRouter() *gin.Engine {
	gorf.Apps = append(apps)
	LoadSettings()
	dbConf := gorf.DbConf{
		Name: "data.db",
	}
	gorf.InitializeDatabase(&dbConf)
	gorf.SetupApps()
	r := gin.Default()
	gorf.RegisterApps(r)
	return r
}

Project Management Board

https://github.com/orgs/go-gorf/projects/1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Apps []GorfApp

array of all registerd apps

View Source
var DB *gorm.DB
View Source
var Settings = GlobalSettings{
	UserObjKey: "user",
	UserObjId:  "id",
}

Functions

func ConnectDB

func ConnectDB(db *DbConf)

func InitializeDatabase

func InitializeDatabase(db *DbConf)

func RegisterApps

func RegisterApps(r *gin.Engine)

Register apps

func SetupApps

func SetupApps()

Setup all apps

Types

type DbConf

type DbConf struct {
	Name string
}

type GlobalSettings

type GlobalSettings struct {
	SecretKey  string
	UserObjKey string
	UserObjId  string
}

Global Project settings

type GorfApp

type GorfApp interface {
	Setup()
	Register(r *gin.Engine)
}

Gorp App interface

Directories

Path Synopsis
backends
dynamodbi module
gormi module
common module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL