Documentation ¶
Index ¶
- Constants
- Variables
- func Get(url string, contentType string, target interface{}) (int, error)
- func GetCoordinates(id int64) (latitude float64, longitude float64)
- func GetEuclideanMatrix(coordinates [][]float64) ([][]int64, error)
- func GetFormattedInterval(fieldName string) string
- func GetFormattedTimestamp(fieldName string) string
- func GetLocationId(latitude float64, longitude float64) int64
- func GetMatrix(locationIds []int64, durationCalc string) (startIds []int64, endIds []int64, durations []int64, err error)
- func GetMatrixFromOSRM(coordinates [][]float64, baseUrl string) ([][]int64, error)
- func GetMatrixFromValhalla(coordinates [][]float64, baseUrl string) ([][]int64, error)
- func GetOutputFields(resourceStruct interface{}, tableName string) (sql string)
- func GetShipmentTimeWindows(kind []*string, timeWindows [][]*string) ([][]string, [][]string)
- func GetTimeWindows(timeWindows [][]*string) [][]string
- func HandleDBError(err error) error
- func Logger(h http.Handler) http.Handler
- func NewValidator() *validator.Validate
- func SerializeICal(calendar []ICal) string
- func ValidateInput(jsonStruct map[string]interface{}, originalStruct interface{}) error
- type ErrorResponse
- type Formatter
- type ICal
- type LocationParams
- type MetadataResponse
- type NotFound
- type PartialSQL
- type ScheduleDB
- type ScheduleData
- type ScheduleDataOverview
- type ScheduleDataTask
- type ScheduleResponse
- type ScheduleRoute
- type ScheduleSummary
- type ScheduleUnassigned
- type StatusRespWr
- type Success
- type SuccessResponse
Constants ¶
View Source
const ScheduleIcal = `` /* 415-byte string literal not displayed */
Example for Schedule in ical format
Variables ¶
View Source
var AliasFields = map[string]string{
"location": "location_id",
"p_location": "p_location_id",
"d_location": "d_location_id",
"start_location": "start_id",
"end_location": "end_id",
}
Functions ¶
func Get ¶ added in v0.2.0
make get request to an url with content-type, and return the response body as json
func GetCoordinates ¶
func GetEuclideanMatrix ¶ added in v0.2.0
func GetFormattedInterval ¶ added in v0.2.0
func GetFormattedTimestamp ¶ added in v0.2.0
func GetLocationId ¶ added in v0.2.0
func GetMatrixFromOSRM ¶ added in v0.2.0
func GetMatrixFromValhalla ¶ added in v0.2.0
func GetOutputFields ¶
func GetShipmentTimeWindows ¶ added in v0.2.0
func GetTimeWindows ¶ added in v0.2.0
func HandleDBError ¶
func NewValidator ¶
func NewValidator() *validator.Validate
func SerializeICal ¶
func ValidateInput ¶
Verify that the type of input user struct is same as the required type
Types ¶
type ErrorResponse ¶ added in v0.2.0
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
func NewFormatter ¶
func NewFormatter() *Formatter
func (*Formatter) FormatICAL ¶
func (*Formatter) FormatJSON ¶
func (r *Formatter) FormatJSON(w http.ResponseWriter, respCode int, data interface{})
func (*Formatter) GetScheduleICal ¶
func (r *Formatter) GetScheduleICal(scheduleData ScheduleData) ([]ICal, string)
type LocationParams ¶
type MetadataResponse ¶ added in v0.2.0
type MetadataResponse struct { Summary []ScheduleSummary `json:"summary"` Unassigned []ScheduleUnassigned `json:"unassigned"` TotalTravel string `json:"total_travel" example:"01:00:00"` TotalSetup string `json:"total_setup" example:"00:05:00"` TotalService string `json:"total_service" example:"00:10:00"` TotalWaiting string `json:"total_waiting" example:"00:30:00"` }
type PartialSQL ¶
type PartialSQL struct { Fields []string Args []interface{} }
func GetPartialSQL ¶
func GetPartialSQL(resource interface{}) PartialSQL
Get an SQL query with partial fields Takes a resource object as parameter, and returns its fields and arguments. (returns only those arguments which are not nil) See https://stackoverflow.com/questions/38206479/golang-rest-patch-and-building-an-update-query
type ScheduleDB ¶ added in v0.2.0
type ScheduleDB struct { Type string `json:"type" example:"job"` ProjectID int64 `json:"project_id,string" example:"1234567812345678"` VehicleID int64 `json:"vehicle_id,string" example:"1234567812345678"` TaskID int64 `json:"task_id,string" example:"1234567812345678"` Location LocationParams `json:"location"` Arrival string `json:"arrival" example:"2021-12-01T13:00:00"` Departure string `json:"departure" example:"2021-12-01T13:00:00"` TravelTime string `json:"travel_time" example:"00:16:40"` SetupTime string `json:"setup_time" example:"00:00:00"` ServiceTime string `json:"service_time" example:"00:02:00"` WaitingTime string `json:"waiting_time" example:"00:00:00"` Load []int64 `json:"load" example:"0,0"` VehicleData interface{} `json:"vehicle_data" swaggertype:"object,string" example:"key1:value1,key2:value2"` TaskData interface{} `json:"task_data" swaggertype:"object,string" example:"key1:value1,key2:value2"` CreatedAt string `json:"created_at" example:"2021-12-01T13:00:00"` UpdatedAt string `json:"updated_at" example:"2021-12-01T13:00:00"` }
type ScheduleData ¶ added in v0.2.0
type ScheduleData struct { Schedule []ScheduleResponse `json:"schedule"` Metadata MetadataResponse `json:"metadata"` ProjectID int64 `json:"project_id,string,omitempty" example:"1234567812345678"` }
type ScheduleDataOverview ¶ added in v0.2.0
type ScheduleDataOverview struct { Metadata MetadataResponse `json:"metadata"` ProjectID int64 `json:"project_id,string,omitempty" example:"1234567812345678"` }
type ScheduleDataTask ¶ added in v0.2.0
type ScheduleDataTask struct { Schedule []ScheduleResponse `json:"schedule"` ProjectID int64 `json:"project_id,string,omitempty" example:"1234567812345678"` }
type ScheduleResponse ¶ added in v0.2.0
type ScheduleResponse struct { VehicleID int64 `json:"vehicle_id,string"` VehicleData interface{} `json:"vehicle_data" swaggertype:"object,string" example:"key1:value1,key2:value2"` Route []ScheduleRoute `json:"route"` }
type ScheduleRoute ¶ added in v0.2.0
type ScheduleRoute struct { Type string `json:"type" example:"job"` TaskID int64 `json:"task_id,string" example:"1234567812345678"` Location LocationParams `json:"location"` Arrival string `json:"arrival" example:"2021-12-01T13:00:00"` Departure string `json:"departure" example:"2021-12-01T13:00:00"` TravelTime string `json:"travel_time" example:"00:16:40"` SetupTime string `json:"setup_time" example:"00:00:00"` ServiceTime string `json:"service_time" example:"00:02:00"` WaitingTime string `json:"waiting_time" example:"00:00:00"` Load []int64 `json:"load" example:"0,0"` TaskData interface{} `json:"task_data" swaggertype:"object,string" example:"key1:value1,key2:value2"` CreatedAt string `json:"created_at" example:"2021-12-01T13:00:00"` UpdatedAt string `json:"updated_at" example:"2021-12-01T13:00:00"` }
type ScheduleSummary ¶ added in v0.2.0
type ScheduleSummary struct { VehicleID int64 `json:"vehicle_id,string" example:"1234567812345678"` TravelTime string `json:"travel_time" example:"00:16:40"` SetupTime string `json:"setup_time" example:"00:00:00"` ServiceTime string `json:"service_time" example:"00:02:00"` WaitingTime string `json:"waiting_time" example:"00:00:00"` VehicleData interface{} `json:"vehicle_data" swaggertype:"object,string" example:"key1:value1,key2:value2"` }
type ScheduleUnassigned ¶ added in v0.2.0
type ScheduleUnassigned struct { Type string `json:"type" example:"job"` TaskID int64 `json:"task_id,string" example:"1234567812345678"` Location LocationParams `json:"location"` TaskData interface{} `json:"task_data" swaggertype:"object,string" example:"key1:value1,key2:value2"` }
type StatusRespWr ¶
type StatusRespWr struct { http.ResponseWriter // We embed http.ResponseWriter // contains filtered or unexported fields }
func (*StatusRespWr) WriteHeader ¶
func (w *StatusRespWr) WriteHeader(status int)
type SuccessResponse ¶ added in v0.2.0
Click to show internal directories.
Click to hide internal directories.