# README
Lumos
Lumos is a collection of library, wrapper and standard library to build a service in Dimall Backend Project.
Main Feature :
- Routing
- Data Query
Add Routing
import web "github.com/dimall-id/lumos/http"
import "net/http"
func Routes () {
err := web.AddRoute(http.Route{
Name: "List of Product",
HttpMethod: "GET",
Url: "/products",
Roles: []string{
"USER",
},
Func: ListOfProductHandler,
}
)
if err != nil {
log.Fatal(err)
}
}
func ListOfProductHandler (r *http.Request) (interface{},web.HttpError) {
return nil,web.HttpError{}
}
Start Web Server
import web "github.com/dimall-id/lumos/http"
func main() {
Routes()
log.Fatal(web.StartHttpServer(":8080"))
}
Query Data
- Date Query
format : field=[date;gt|gte|eq|neq:mm-dd-yyyy,lt|lte:mm-dd-yyyy]
example :
- date=[date;gt:01-20-2020,lt:01-22-2020]
- date=[date;eq:01-20-2020]
- Numeric Query
format : field=[numeric;gt|gte|eq|neq:0-9,lt|lte:0-9]
example :
- price=[numeric;gt:1000,lte:10000]
- price=[numeric;neq:100000]
- List Query
format : field=[in|nin;value,value,...]
example :
- id=[in;1,2,3,4]
- id=[nin;1,2,3,4]
- Order Query
format : order=[order;field:asc|desc,field:asc|desc,...]
example :
- order=[order;name:asc,price:desc]
- Paging Query
format : paging=[page=0-9,per_page=0-9]
example :
- paging=[page=1,per_page=10]
- With Query
format : with=[with;relation,relation,...]
example :
- with=[with;ProductImage,ProductCategories]
- Select Query
format : select=[select;field,field,field,...]
example :
- select=[select;id,name,price]
- String Query
format : field=[eq|neq|like;value]
example
- name=[eq;Product A]
- name=[neq;Product B]
- name=[like;%Produc%]
Setup Query at Handler
import "gorm.io/gorm"
import "github.com/dimall-id/lumos/data"
func ListOfProductHandler (r *http.Request) (interface{},web.HttpError) {
tx := db.Open(...)
tx.Model(Product)
Q = data.New(tx)
var data []Product
response := Q.BuildResponse(r, &data)
return response, http.HttpError{}
}
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author