diff --git a/controller.go b/controller.go index 8dabedd9..0586bc62 100644 --- a/controller.go +++ b/controller.go @@ -309,6 +309,9 @@ func (rc RestController) Patch(ctx Context) error { return err1 } + // Set prefer representation header as default + ctx.RequestContext().Request.Header.Add("Prefer", "return=representation") + return RestProxy(ctx, rc.TableName) } @@ -332,6 +335,9 @@ func (rc RestController) Post(ctx Context) error { return err1 } + // Set prefer representation header as default + ctx.RequestContext().Request.Header.Add("Prefer", "return=representation") + return RestProxy(ctx, rc.TableName) } @@ -347,6 +353,9 @@ func (rc RestController) Put(ctx Context) error { return err1 } + // Set prefer representation header as default + ctx.RequestContext().Request.Header.Add("Prefer", "return=representation") + return RestProxy(ctx, rc.TableName) } diff --git a/pkg/db/relation.go b/pkg/db/relation.go index 04666b23..ac3fd6b6 100644 --- a/pkg/db/relation.go +++ b/pkg/db/relation.go @@ -32,7 +32,7 @@ func (q *Query) Preload(table string, args ...string) *Query { relations := strings.Split(table, ".") if len(relations) > 3 { - raiden.Fatal("unsupported nested relations more than 3 levels") + raiden.Panic("unsupported nested relations more than 3 levels") } for i, relation := range relations { @@ -48,7 +48,7 @@ func (q *Query) Preload(table string, args ...string) *Query { } if err != nil { - raiden.Fatal("could not find related model.") + raiden.Panic("could not find related model.") } relatedModelStruct := reflect.TypeOf(relatedModel) @@ -80,7 +80,7 @@ func (q *Query) Preload(table string, args ...string) *Query { relatedForeignKey, err = getTagValue(join, "foreignKey") if err != nil { - raiden.Fatal("could not find foreign key in join tag.") + raiden.Panic("could not find foreign key in join tag.") } } } diff --git a/pkg/db/select.go b/pkg/db/select.go index edb255ab..7bc7af6e 100644 --- a/pkg/db/select.go +++ b/pkg/db/select.go @@ -23,7 +23,7 @@ func (q Query) Select(columns []string) (model *Query) { column = split[1] if !isValidColumnName(alias) { err := fmt.Sprintf("invalid alias column name: \"%s\" name is invalid.", alias) - raiden.Fatal(err) + raiden.Panic(err) } } else { column = c