session

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SimsessionPathParam = "simsession"
	DriverIDPathParam   = "driver_id"
)
View Source
const SubsessionIDPathParam = "subsession_id"

Variables

This section is empty.

Functions

func NewGetLapsEndpoint

func NewGetLapsEndpoint(client LapDataClient) http.Handler

func NewGetSessionEndpoint

func NewGetSessionEndpoint(client IRacingClient) http.Handler

func NewRouter

func NewRouter(client CombinedClient, authMiddleware func(http.Handler) http.Handler) http.Handler

Types

type AllowedLicense

type AllowedLicense struct {
	GroupName       string `json:"groupName"`
	LicenseGroup    int    `json:"licenseGroup"`
	MaxLicenseLevel int    `json:"maxLicenseLevel"`
	MinLicenseLevel int    `json:"minLicenseLevel"`
	ParentID        int    `json:"parentId"`
}

type CarClass

type CarClass struct {
	CarClassID      int          `json:"carClassId"`
	ShortName       string       `json:"shortName"`
	Name            string       `json:"name"`
	StrengthOfField int          `json:"strengthOfField"`
	NumEntries      int          `json:"numEntries"`
	CarsInClass     []CarInClass `json:"carsInClass"`
}

type CarInClass

type CarInClass struct {
	CarID int `json:"carId"`
}

type CombinedClient

type CombinedClient interface {
	IRacingClient
	LapDataClient
}

CombinedClient combines all iRacing client methods needed by session endpoints.

type DriverResult

type DriverResult struct {
	CustID                  int64     `json:"custId"`
	DisplayName             string    `json:"displayName"`
	AggregateChampPoints    int       `json:"aggregateChampPoints"`
	AI                      bool      `json:"ai"`
	AverageLap              int       `json:"averageLap"`
	BestLapNum              int       `json:"bestLapNum"`
	BestLapTime             int       `json:"bestLapTime"`
	BestNLapsNum            int       `json:"bestNlapsNum"`
	BestNLapsTime           int       `json:"bestNlapsTime"`
	BestQualLapAt           time.Time `json:"bestQualLapAt"`
	BestQualLapNum          int       `json:"bestQualLapNum"`
	BestQualLapTime         int       `json:"bestQualLapTime"`
	CarClassID              int       `json:"carClassId"`
	CarClassName            string    `json:"carClassName"`
	CarClassShortName       string    `json:"carClassShortName"`
	CarID                   int64     `json:"carId"`
	CarName                 string    `json:"carName"`
	CarCfg                  int       `json:"carCfg"`
	ChampPoints             int       `json:"champPoints"`
	ClassInterval           int       `json:"classInterval"`
	CountryCode             string    `json:"countryCode"`
	Division                int       `json:"division"`
	DivisionName            string    `json:"divisionName"`
	DropRace                bool      `json:"dropRace"`
	FinishPosition          int       `json:"finishPosition"`
	FinishPositionInClass   int       `json:"finishPositionInClass"`
	FlairID                 int       `json:"flairId"`
	FlairName               string    `json:"flairName"`
	FlairShortname          string    `json:"flairShortname"`
	Friend                  bool      `json:"friend"`
	Helmet                  Helmet    `json:"helmet"`
	Incidents               int       `json:"incidents"`
	Interval                int       `json:"interval"`
	LapsComplete            int       `json:"lapsComplete"`
	LapsLead                int       `json:"lapsLead"`
	LeagueAggPoints         int       `json:"leagueAggPoints"`
	LeaguePoints            int       `json:"leaguePoints"`
	LicenseChangeOval       int       `json:"licenseChangeOval"`
	LicenseChangeRoad       int       `json:"licenseChangeRoad"`
	Livery                  Livery    `json:"livery"`
	MaxPctFuelFill          int       `json:"maxPctFuelFill"`
	NewCPI                  float64   `json:"newCpi"`
	NewLicenseLevel         int       `json:"newLicenseLevel"`
	NewSubLevel             int       `json:"newSubLevel"`
	NewTTRating             int       `json:"newTtrating"`
	NewIRating              int       `json:"newIrating"`
	OldCPI                  float64   `json:"oldCpi"`
	OldLicenseLevel         int       `json:"oldLicenseLevel"`
	OldSubLevel             int       `json:"oldSubLevel"`
	OldTTRating             int       `json:"oldTtrating"`
	OldIRating              int       `json:"oldIrating"`
	OptLapsComplete         int       `json:"optLapsComplete"`
	Position                int       `json:"position"`
	QualLapTime             int       `json:"qualLapTime"`
	ReasonOut               string    `json:"reasonOut"`
	ReasonOutID             int       `json:"reasonOutId"`
	StartingPosition        int       `json:"startingPosition"`
	StartingPositionInClass int       `json:"startingPositionInClass"`
	Suit                    Suit      `json:"suit"`
	Watched                 bool      `json:"watched"`
	WeightPenaltyKg         int       `json:"weightPenaltyKg"`
}

type Helmet

type Helmet struct {
	Pattern    int    `json:"pattern"`
	Color1     string `json:"color1"`
	Color2     string `json:"color2"`
	Color3     string `json:"color3"`
	FaceType   int    `json:"faceType"`
	HelmetType int    `json:"helmetType"`
}

type IRacingClient

type IRacingClient interface {
	GetSessionResults(ctx context.Context, accessToken string, subsessionID int64, opts ...iracing.GetSessionResultsOption) (*iracing.SessionResult, error)
}

type Lap

type Lap struct {
	LapNumber       int      `json:"lapNumber"`
	Flags           int      `json:"flags"`
	Incident        bool     `json:"incident"`
	SessionTime     int      `json:"sessionTime"`
	LapTime         int      `json:"lapTime"`
	PersonalBestLap bool     `json:"personalBestLap"`
	LapEvents       []string `json:"lapEvents"`
}

Lap represents a single lap's timing and event data.

type LapDataClient

type LapDataClient interface {
	GetLapData(ctx context.Context, accessToken string, subsessionID int64, simsessionNumber int, opts ...iracing.GetLapDataOption) (*iracing.LapDataResponse, error)
}

type LapDataResponse

type LapDataResponse struct {
	BestLapNum      int       `json:"bestLapNum"`
	BestLapTime     int       `json:"bestLapTime"`
	BestNLapsNum    int       `json:"bestNlapsNum"`
	BestNLapsTime   int       `json:"bestNlapsTime"`
	BestQualLapNum  int       `json:"bestQualLapNum"`
	BestQualLapTime int       `json:"bestQualLapTime"`
	BestQualLapAt   time.Time `json:"bestQualLapAt"`
	CustID          int64     `json:"custId"`
	Name            string    `json:"name"`
	CarID           int       `json:"carId"`
	LicenseLevel    int       `json:"licenseLevel"`
	Laps            []Lap     `json:"laps"`
}

LapDataResponse is the API response for lap data.

type Livery

type Livery struct {
	CarID        int     `json:"carId"`
	Pattern      int     `json:"pattern"`
	Color1       string  `json:"color1"`
	Color2       string  `json:"color2"`
	Color3       string  `json:"color3"`
	NumberFont   int     `json:"numberFont"`
	NumberColor1 string  `json:"numberColor1"`
	NumberColor2 string  `json:"numberColor2"`
	NumberColor3 string  `json:"numberColor3"`
	NumberSlant  int     `json:"numberSlant"`
	Sponsor1     int     `json:"sponsor1"`
	Sponsor2     int     `json:"sponsor2"`
	CarNumber    string  `json:"carNumber"`
	WheelColor   *string `json:"wheelColor"`
	RimType      int     `json:"rimType"`
}

type RaceSummary

type RaceSummary struct {
	SubsessionID         int64  `json:"subsessionId"`
	AverageLap           int    `json:"averageLap"`
	LapsComplete         int    `json:"lapsComplete"`
	NumCautions          int    `json:"numCautions"`
	NumCautionLaps       int    `json:"numCautionLaps"`
	NumLeadChanges       int    `json:"numLeadChanges"`
	FieldStrength        int    `json:"fieldStrength"`
	NumOptLaps           int    `json:"numOptLaps"`
	HasOptPath           bool   `json:"hasOptPath"`
	SpecialEventType     int    `json:"specialEventType"`
	SpecialEventTypeText string `json:"specialEventTypeText"`
}

type SessionResponse

type SessionResponse struct {
	SubsessionID            int64              `json:"subsessionId"`
	DriverRaceId            *int64             `json:"driverRaceId,omitempty"`
	SessionID               int64              `json:"sessionId"`
	AllowedLicenses         []AllowedLicense   `json:"allowedLicenses"`
	AssociatedSubsessionIDs []int64            `json:"associatedSubsessionIds"`
	CanProtest              bool               `json:"canProtest"`
	CarClasses              []CarClass         `json:"carClasses"`
	CautionType             int                `json:"cautionType"`
	CooldownMinutes         int                `json:"cooldownMinutes"`
	CornersPerLap           int                `json:"cornersPerLap"`
	DamageModel             int                `json:"damageModel"`
	DriverChangeParam1      int                `json:"driverChangeParam1"`
	DriverChangeParam2      int                `json:"driverChangeParam2"`
	DriverChangeRule        int                `json:"driverChangeRule"`
	DriverChanges           bool               `json:"driverChanges"`
	EndTime                 time.Time          `json:"endTime"`
	EventAverageLap         int                `json:"eventAverageLap"`
	EventBestLapTime        int                `json:"eventBestLapTime"`
	EventLapsComplete       int                `json:"eventLapsComplete"`
	EventStrengthOfField    int                `json:"eventStrengthOfField"`
	EventType               int                `json:"eventType"`
	EventTypeName           string             `json:"eventTypeName"`
	HeatInfoID              int                `json:"heatInfoId"`
	LicenseCategory         string             `json:"licenseCategory"`
	LicenseCategoryID       int                `json:"licenseCategoryId"`
	LimitMinutes            int                `json:"limitMinutes"`
	MaxTeamDrivers          int                `json:"maxTeamDrivers"`
	MaxWeeks                int                `json:"maxWeeks"`
	MinTeamDrivers          int                `json:"minTeamDrivers"`
	NumCautionLaps          int                `json:"numCautionLaps"`
	NumCautions             int                `json:"numCautions"`
	NumDrivers              int                `json:"numDrivers"`
	NumLapsForQualAverage   int                `json:"numLapsForQualAverage"`
	NumLapsForSoloAverage   int                `json:"numLapsForSoloAverage"`
	NumLeadChanges          int                `json:"numLeadChanges"`
	OfficialSession         bool               `json:"officialSession"`
	PointsType              string             `json:"pointsType"`
	PrivateSessionID        int                `json:"privateSessionId"`
	RaceSummary             RaceSummary        `json:"raceSummary"`
	RaceWeekNum             int                `json:"raceWeekNum"`
	ResultsRestricted       bool               `json:"resultsRestricted"`
	SeasonID                int                `json:"seasonId"`
	SeasonName              string             `json:"seasonName"`
	SeasonQuarter           int                `json:"seasonQuarter"`
	SeasonShortName         string             `json:"seasonShortName"`
	SeasonYear              int                `json:"seasonYear"`
	SeriesID                int                `json:"seriesId"`
	SeriesName              string             `json:"seriesName"`
	SeriesShortName         string             `json:"seriesShortName"`
	SessionResults          []SimSessionResult `json:"sessionResults"`
	SessionSplits           []SessionSplit     `json:"sessionSplits"`
	SpecialEventType        int                `json:"specialEventType"`
	StartTime               time.Time          `json:"startTime"`
	Track                   Track              `json:"track"`
	TrackState              TrackState         `json:"trackState"`
	Weather                 Weather            `json:"weather"`
}

SessionResponse is the API response for session results.

type SessionSplit

type SessionSplit struct {
	SubsessionID         int64 `json:"subsessionId"`
	EventStrengthOfField int   `json:"eventStrengthOfField"`
}

type SimSessionResult

type SimSessionResult struct {
	SimsessionNumber   int            `json:"simsessionNumber"`
	SimsessionName     string         `json:"simsessionName"`
	SimsessionType     int            `json:"simsessionType"`
	SimsessionTypeName string         `json:"simsessionTypeName"`
	SimsessionSubtype  int            `json:"simsessionSubtype"`
	WeatherResult      WeatherResult  `json:"weatherResult"`
	Results            []DriverResult `json:"results"`
}

type Suit

type Suit struct {
	Pattern int    `json:"pattern"`
	Color1  string `json:"color1"`
	Color2  string `json:"color2"`
	Color3  string `json:"color3"`
}

type Track

type Track struct {
	TrackID    int64  `json:"trackId"`
	TrackName  string `json:"trackName"`
	ConfigName string `json:"configName"`
	Category   string `json:"category"`
	CategoryID int    `json:"categoryId"`
}

type TrackState

type TrackState struct {
	LeaveMarbles   bool `json:"leaveMarbles"`
	PracticeRubber int  `json:"practiceRubber"`
	QualifyRubber  int  `json:"qualifyRubber"`
	RaceRubber     int  `json:"raceRubber"`
	WarmupRubber   int  `json:"warmupRubber"`
}

type Weather

type Weather struct {
	AllowFog                      bool    `json:"allowFog"`
	Fog                           int     `json:"fog"`
	PrecipMM2HrBeforeFinalSession float64 `json:"precipMm2hrBeforeFinalSession"`
	PrecipMMFinalSession          float64 `json:"precipMmFinalSession"`
	PrecipOption                  int     `json:"precipOption"`
	PrecipTimePct                 float64 `json:"precipTimePct"`
	RelHumidity                   int     `json:"relHumidity"`
	SimulatedStartTime            string  `json:"simulatedStartTime"`
	Skies                         int     `json:"skies"`
	TempUnits                     int     `json:"tempUnits"`
	TempValue                     int     `json:"tempValue"`
	TimeOfDay                     int     `json:"timeOfDay"`
	TrackWater                    int     `json:"trackWater"`
	Type                          int     `json:"type"`
	Version                       int     `json:"version"`
	WeatherVarInitial             int     `json:"weatherVarInitial"`
	WeatherVarOngoing             int     `json:"weatherVarOngoing"`
	WindDir                       int     `json:"windDir"`
	WindUnits                     int     `json:"windUnits"`
	WindValue                     int     `json:"windValue"`
}

type WeatherResult

type WeatherResult struct {
	AvgSkies                 int     `json:"avgSkies"`
	AvgCloudCoverPct         float64 `json:"avgCloudCoverPct"`
	MinCloudCoverPct         float64 `json:"minCloudCoverPct"`
	MaxCloudCoverPct         float64 `json:"maxCloudCoverPct"`
	TempUnits                int     `json:"tempUnits"`
	AvgTemp                  float64 `json:"avgTemp"`
	MinTemp                  float64 `json:"minTemp"`
	MaxTemp                  float64 `json:"maxTemp"`
	AvgRelHumidity           float64 `json:"avgRelHumidity"`
	WindUnits                int     `json:"windUnits"`
	AvgWindSpeed             float64 `json:"avgWindSpeed"`
	MinWindSpeed             float64 `json:"minWindSpeed"`
	MaxWindSpeed             float64 `json:"maxWindSpeed"`
	AvgWindDir               int     `json:"avgWindDir"`
	MaxFog                   float64 `json:"maxFog"`
	FogTimePct               float64 `json:"fogTimePct"`
	PrecipTimePct            float64 `json:"precipTimePct"`
	PrecipMM                 float64 `json:"precipMm"`
	PrecipMM2HrBeforeSession float64 `json:"precipMm2hrBeforeSession"`
	SimulatedStartTime       string  `json:"simulatedStartTime"`
}

Jump to

Keyboard shortcuts

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