Skip to content

Instantly share code, notes, and snippets.

@hauxe
Created July 3, 2018 08:46
Show Gist options
  • Save hauxe/1db07c0adff7bdeda4a500fa720c47be to your computer and use it in GitHub Desktop.
Save hauxe/1db07c0adff7bdeda4a500fa720c47be to your computer and use it in GitHub Desktop.
func (crud *CRUD) registerL() gomHTTP.ServerRoute {
// build list sql
fields := crud.Config.listFields
if len(fields) == 0 {
// allow update all fields
fields = crud.Config.fields
}
fieldNames := make([]string, len(fields))
for i, field := range fields {
fieldNames[i] = field.name
}
crud.Config.listedFields = fields
crud.Config.sqlCRUDList = fmt.Sprintf(sqlCRUDList, "`"+strings.Join(fieldNames, "`,`")+"`",
crud.Config.TableName, crud.Config.pk.name)
fmt.Println(crud.Config.sqlCRUDList)
return gomHTTP.ServerRoute{
Name: "crud_list_" + crud.Config.TableName,
Method: http.MethodGet,
Path: fmt.Sprintf("/%s/list", crud.Config.TableName),
Handler: crud.handleList,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment