Documentation
¶
Index ¶
- Variables
- func MarshalStackSkip(skip int) func(err error) interface{}
- func MustAdmin(out *ent.Admin) echo.HandlerFunc
- func MustAdminContext(out *appctx.AdminContext) echo.HandlerFunc
- func MustRqlParser(config rql.Config) *rql.Parser
- func Parse(parser Parser, parsers ...Parser) echo.HandlerFunc
- func ParseUrlQuery(v string) string
- func Response(c echo.Context, opts ...response.ReponseOption) error
- func Validate(parser Parser, parsers ...Parser) echo.HandlerFunc
- type Parser
Constants ¶
This section is empty.
Variables ¶
View Source
var ( StackSourceFileName = "source" StackSourceLineName = "line" StackSourceFunctionName = "func" )
View Source
var IsProduction bool
Nothing to describe this fucking variable.
Functions ¶
func MarshalStackSkip ¶
func MustAdmin ¶
func MustAdmin(out *ent.Admin) echo.HandlerFunc
required middleware jwtService.RequiredAdmin()
func MustAdminContext ¶
func MustAdminContext(out *appctx.AdminContext) echo.HandlerFunc
required middleware jwtService.RequiredAdmin()
func MustRqlParser ¶
Model is the resource definition. The parser is configured based on the its definition. For example, given the following struct definition: note: for admin only
type User struct {
Age int `rql:"filter,sort"`
Name string `rql:"filter"`
}
Json
{
"limit": 25,
"offset": 0,
"filter": {
"isEnable": true,
"createdAt": {
"$gt": "2018-01-01T16:00:00.000Z",
"$lt": "2018-04-01T16:00:00.000Z"
}
"$or": [
{ "isEnable": false },
{ "address": "NYC" }
]
}
"sort": ["-id","createdAt","+isEnable"]
}
func Parse ¶
func Parse(parser Parser, parsers ...Parser) echo.HandlerFunc
simple parser Parse(BodyParser(&body),ParamsParser(out))
func ParseUrlQuery ¶
ParseUrlQuery
queries := "filter[money][gt]=true&limit=10"
expected := `{"filter":{"money":{"gt":true}},"limit":100}`
func Response ¶
func Response(c echo.Context, opts ...response.ReponseOption) error
A fuction to return beautiful and structured responses.
Response(c,response.Data(...))
{
code:0,
message:"OK"
data:any
}
Response(c)
{
code:0,
message:"OK"
data:any
}
Response(c,response.Error(...))
{
code:-5,
message:".....error"
}
Types ¶
type Parser ¶
func BodyParser ¶
BodyParser(&Person{})
type User struct {
ID string `param:"id" query:"id" form:"id" json:"id" xml:"id"`
}
Swagger
// @Param <name> <params-type> <value-type> <required> <description> // @Param info body dto.RouteRequest true "Route Info"
func ParamsParser ¶
ParamsParser(¶m{})
param := new(struct {ID uint `param:"id"`})
Swagger
// @Param <name> <params-type> <value-type> <required> <description> // @Param id path int true "Route ID"
func QueryParser ¶
QueryParser(&Person{})
type Person struct {
Name string `query:"name"`
Pass string `query:"pass"`
Products []string `query:"products"`
}
Swagger
// @Param <name> <params-type> <value-type> <required> <description> // @Param person query dto.Person true "person info"
func RqlQueryParser ¶
@Required: meta.use(RQL(...))
{
"limit": 25,
"filter": {
"admin": false,
"createdAt": {
"$gt": "2018-01-01T16:00:00.000Z",
"$lt": "2018-04-01T16:00:00.000Z"
}
"$or": [
{ "address": "TLV" },
{ "address": "NYC" }
]
}
"sort": ["-createdAt"]
}
Click to show internal directories.
Click to hide internal directories.