Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Info ¶
Info contains fields to patch and model with patched data. See Map for more information.
type Map ¶
type Map struct { Invalid bool // contains filtered or unexported fields }
Map represents a mapping between structure tag values and their corresponding struct field names Input map is set using "From" methods, Output map is set using "To" methods patch.Map are generated by a global mapper, which is configured to look for specific struct tag for input and output As an example, a patch.Map of this model (with a mapper using json & sql tags):
type TestModel struct { First string `json:"json_first,omitempty" sql:"db_first"` Second string `json:"json_second" sql:"db_second"` Third string Fourth string `sql:"db_fourth"` Fifth string `json:"json_fifth"` }
would have an input {"json_first": "First", "json_second": "Second", "fifth_field": "Fifth"} and a output {"First": "db_first", "Second": "db_second", "Fourth": `db_fourth`} The interest of this struct is to handle resources patching from a request to final storer
func FromHTTP ¶
FromHTTP decode a HTTP request into a ready-to-be-used patch.Map It does define JSON keys found inside request body as input map It ignores errors if faced, considering it should be handled outside of this function It instantiates later used output map and it does restaure body's io.Reader after consuming it
func (Map) GetInfo ¶
GetInfo converts a patch.Map into a patch.Info
type Mapper ¶
type Mapper struct {
// contains filtered or unexported fields
}
Mapper is a component loading and saving in memory patch.Maps for requested models in real time everytime a patch.Maps is requested for a model, the mapper is involved in order to know either the model has been already mapped or not this allows us to mitigate the use of struct reflection