Created
July 3, 2018 08:46
-
-
Save hauxe/1db07c0adff7bdeda4a500fa720c47be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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