models

package
v0.0.0-...-a52d1cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogEntry

type LogEntry struct {
	ID        uint      `gorm:"primaryKey" json:"id"`
	Producer  string    `gorm:"index:idx_producer" json:"producer"`
	Message   string    `gorm:"type:text" json:"message"`
	CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
}

func (*LogEntry) Bind

func (logEntry *LogEntry) Bind(request *http.Request) error

func (*LogEntry) Render

func (*LogEntry) Render(writer http.ResponseWriter, request *http.Request) error

type LogEntryList

type LogEntryList struct {
	LogEntries []*LogEntry `json:"log_entries" gorm:"-"`
}

func (*LogEntryList) Render

func (*LogEntryList) Render(writer http.ResponseWriter, request *http.Request) error

type LogEntryRequest

type LogEntryRequest struct {
	*LogEntry

	ProtectedID string `json:"id"` // override 'id' json to have more control
}

LogEntryRequest is the request payload for LogEntry data model.

NOTE: It's good practice to have well defined request and response payloads so you can manage the specific inputs and outputs for clients, and also gives you the opportunity to transform data on input or output, for example on request, we'd like to protect certain fields and on output perhaps we'd like to include a computed field based on other values that aren't in the data model. Also, check out this awesome blog post on struct composition: http://attilaolah.eu/2014/09/10/json-and-struct-composition-in-go/

func (*LogEntryRequest) Bind

func (logEntryRequest *LogEntryRequest) Bind(request *http.Request) error

type LogEntryResponse

type LogEntryResponse struct {
	*LogEntry
}

func (*LogEntryResponse) Render

func (logEntry *LogEntryResponse) Render(writer http.ResponseWriter, request *http.Request) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL