KaGo
Kmux is faster using combination of safemap and radix tree , also it does not have param routing conflicts, you can have /test/user and /test/:table, if exact route match for the first , the request handled only by the first , otherwise if something like /test/something -> /test/:table
Kmux also can generate swagger docs from you code or from comments
Ksbus and Korm are perfect combination, allowing you to sync your servers and clients python and javascript all togethers
KaGo is a Django like web framework, that encourages clean and rapid development.
You can start a new project using 2 lines of code, run a high performance server with CRUD Admin Dashboard, interactive shell, easy and performant ORM, AutoSSL and lots more...
List of packages extracted from kago in order to make it more composable :
Quick List of latest features :
/logs running with flag go run main.go --logsgo run main.go shell/docs running with flag go run main.go --docs with dedicated package docs to help you manipulate docs.json file/metrics running with flag go run main.go --monitoring/debug/pprof/(heap|profile\trace) running with flag go run main.go --profilerJoin our discussions here
go get -u github.com/kamalshkeir/[email protected]go get github.com/kamalshkeir/sqlitedriver
go get github.com/kamalshkeir/pgdriver
go get github.com/kamalshkeir/mysqldriverpackage main
import (
"github.com/kamalshkeir/kago"
"github.com/kamalshkeir/sqlitedriver"
"github.com/kamalshkeir/mysqldriver"
"github.com/kamalshkeir/pgdriver"
)
func main() {
sqlitedriver.Use() // use one of this drivers
mysqldriver.Use()
pgdriver.Use()
app := kago.New() // router + admin + database + shell
app.Run()
}package main
import (
"github.com/kamalshkeir/kago"
)
func main() {
app := kago.BareBone() // router only, bot need for sql drivers
app.Run()
}go run main.gogo run main.go shell
-> createsuperuser# run localy:
go run main.go # default: -h localhost -p 9313go run main.go -h example.com -p 443 --cert cerkey.pem --key privkey.pemgo run main.go -h example.com -p 443
# this will generate 2 certificates from letsencrypt example.com and www.example.com to directory ./certsgo run main.go -h example.com -p 443 -domains a.example.com, b.example.com,... # most important tags and env vars that you can override:
HOST -h DEFAULT: "localhost"
PORT -p DEFAULT: "9313"
DOMAINS -domains DEFAULT: ""
CERT -cert DEFAULT: ""
KEY -key DEFAULT: ""
PROFILER -profiler DEFAULT: false
DOCS -docs DEFAULT: false
LOGS -logs DEFAULT: false
MONITORING -monitoring DEFAULT: falsego install github.com/kamalshkeir/kago/cmd/katcherThen you can run:
katcher --root ${PWD} (will watch all files at root)
katcher --root ${PWD} --watch assets/templates,assets/static (will watch only '${PWD}/assets/templates' and '${PWD}/assets/static' folders)settings.REPO_USER="YOUR_REPO_USER" // default kamalshkeir
settings.REPO_NAME="YOUR_REPO_NAME" // default kago-assetsfor example, to override the handler at GET /admin/login:
app.GET("/admin/login",func(c *kamux.Context) {
...
})
// this will add another handler, and remove the old one completely
// so it is very safe to do it this way also………func main() {
app := kago.New()
// will be hitted every 1-2 sec, you can check anything if change and send data on the fly using c.StreamResponse
app.SSE("/sse/logs",func(c *kamux.Context) {
lenStream := len(logger.StreamLogs)
if lenStream > 0 {
lastOne := lenStream-1
err := c.StreamResponse(logger.StreamLogs[lastOne])
if err == nil{
logger.StreamLogs=[]string{}
}
}
})
app.Run()
}……func main() {
app := kago.New()
app.POST("/ajax", func(c *kamux.Context) {
// get json body to map[string]any
requestData := c.BodyJson()
if email,ok := requestData["email"]; ok {
...
}
if err != nil {
c.Status(400).Json(kamux.M{
"error":"User doesn not Exist",
})
}
})
app.Run()
}……// USAGE:
r.GET("/admin", kamux.Admin(IndexView)) // will check from session cookie if user.is_admin is true
r.GET("/admin/login",kamux.Auth(LoginView)) // will get session from cookies decrypt it and validate it
r.GET("/test",kamux.BasicAuth(LoginView,"username","password"))orm.UseCache=falseorm.NewDatabaseFromDSN(dbType,dbName string,dbDSN ...string) (error)
orm.NewDatabaseFromConnection(dbType,dbName string,conn *sql.DB) (error)
orm.GetConnection(dbName ...string) // GetConnection return default connection for orm.DefaultDatabase (if dbName not given or "" or "default") else it return the specified one
orm.UseForAdmin(dbName string) // UseForAdmin use specific database in admin panel if manymatched db
orm.ManyToMany(table1, table2 string, dbName ...string) error // create m2m_table1_table2 table relationsorm.GetAllTables(dbName ...string) []string // if dbName not given, .env used instead to default the db to get all tables in the given db
orm.GetAllColumnsTypes(table string, dbName ...string) map[string]string // clear i think
orm.CreateUser(email,password string,isAdmin int, dbName ...string) error // password will be hashed using argon2go run main.go shell#String Field:
Without parameter With parameter
* text (create column as TEXT not VARCHAR)
* notnull
* unique
* iunique // insensitive unique
* index, +index, index+ (INDEX ascending)
* index-, -index (INDEX descending)
* default (DEFAULT '')* default:'any' (DEFAULT 'any')
* mindex:...
* uindex:username,Iemail // CREATE UNIQUE INDEX ON users (username,LOWER(email))
// email is lower because of 'I' meaning Insensitive for email
* fk:...
* size:50 (VARCHAR(50))
* check:...Without parameter
* - (To Ignore a field)
* autoinc, pk (PRIMARY K暂无开放 Issues,或尚未同步最近议题。