...

Package openapi

import "go.formulabun.club/translator/server/go"
Overview
Index

Overview ▾

Index ▾

Variables
func AssertFileNeededInnerRequired(obj FileNeededInner) error
func AssertPlayerInfoEntryRequired(obj PlayerInfoEntry) error
func AssertPlayerInfoRequired(obj PlayerInfo) error
func AssertRecurseFileNeededInnerRequired(objSlice interface{}) error
func AssertRecurseInterfaceRequired(obj interface{}, callback func(interface{}) error) error
func AssertRecursePlayerInfoEntryRequired(objSlice interface{}) error
func AssertRecursePlayerInfoRequired(objSlice interface{}) error
func AssertRecurseServerInfoRequired(objSlice interface{}) error
func AssertRecurseValueRequired(value reflect.Value, callback func(interface{}) error) error
func AssertServerInfoRequired(obj ServerInfo) error
func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse)
func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error
func IsZeroValue(val interface{}) bool
func Logger(inner http.Handler, name string) http.Handler
func NewRouter(routers ...Router) *mux.Router
func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)
func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error)
type DefaultApiController
    func (c *DefaultApiController) FilesGet(w http.ResponseWriter, r *http.Request)
    func (c *DefaultApiController) PlayerinfoGet(w http.ResponseWriter, r *http.Request)
    func (c *DefaultApiController) Routes() Routes
    func (c *DefaultApiController) ServerinfoGet(w http.ResponseWriter, r *http.Request)
type DefaultApiOption
    func WithDefaultApiErrorHandler(h ErrorHandler) DefaultApiOption
type DefaultApiRouter
type DefaultApiService
    func (s *DefaultApiService) FilesGet(ctx context.Context) (ImplResponse, error)
    func (s *DefaultApiService) PlayerinfoGet(ctx context.Context) (ImplResponse, error)
    func (s *DefaultApiService) ServerinfoGet(ctx context.Context) (ImplResponse, error)
type DefaultApiServicer
    func NewDefaultApiService(target string) DefaultApiServicer
type ErrorHandler
type FileNeededInner
type ImplResponse
    func Response(code int, body interface{}) ImplResponse
type ParsingError
    func (e *ParsingError) Error() string
    func (e *ParsingError) Unwrap() error
type PlayerInfo
type PlayerInfoEntry
type RequiredError
    func (e *RequiredError) Error() string
type Route
type Router
    func NewDefaultApiController(s DefaultApiServicer, opts ...DefaultApiOption) Router
type Routes
type ServerInfo

Package files

api.go api_default.go api_default_service.go error.go helpers.go impl.go logger.go model_file_needed_inner.go model_player_info.go model_player_info_entry.go model_server_info.go routers.go

Variables

var (
    // ErrTypeAssertionError is thrown when type an interface does not match the asserted type
    ErrTypeAssertionError = errors.New("unable to assert type")
)

func AssertFileNeededInnerRequired

func AssertFileNeededInnerRequired(obj FileNeededInner) error

AssertFileNeededInnerRequired checks if the required fields are not zero-ed

func AssertPlayerInfoEntryRequired

func AssertPlayerInfoEntryRequired(obj PlayerInfoEntry) error

AssertPlayerInfoEntryRequired checks if the required fields are not zero-ed

func AssertPlayerInfoRequired

func AssertPlayerInfoRequired(obj PlayerInfo) error

AssertPlayerInfoRequired checks if the required fields are not zero-ed

func AssertRecurseFileNeededInnerRequired

func AssertRecurseFileNeededInnerRequired(objSlice interface{}) error

AssertRecurseFileNeededInnerRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of FileNeededInner (e.g. [][]FileNeededInner), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseInterfaceRequired

func AssertRecurseInterfaceRequired(obj interface{}, callback func(interface{}) error) error

AssertRecurseInterfaceRequired recursively checks each struct in a slice against the callback. This method traverse nested slices in a preorder fashion.

func AssertRecursePlayerInfoEntryRequired

func AssertRecursePlayerInfoEntryRequired(objSlice interface{}) error

AssertRecursePlayerInfoEntryRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of PlayerInfoEntry (e.g. [][]PlayerInfoEntry), otherwise ErrTypeAssertionError is thrown.

func AssertRecursePlayerInfoRequired

func AssertRecursePlayerInfoRequired(objSlice interface{}) error

AssertRecursePlayerInfoRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of PlayerInfo (e.g. [][]PlayerInfo), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseServerInfoRequired

func AssertRecurseServerInfoRequired(objSlice interface{}) error

AssertRecurseServerInfoRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of ServerInfo (e.g. [][]ServerInfo), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseValueRequired

func AssertRecurseValueRequired(value reflect.Value, callback func(interface{}) error) error

AssertRecurseValueRequired checks each struct in the nested slice against the callback. This method traverse nested slices in a preorder fashion.

func AssertServerInfoRequired

func AssertServerInfoRequired(obj ServerInfo) error

AssertServerInfoRequired checks if the required fields are not zero-ed

func DefaultErrorHandler

func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse)

DefaultErrorHandler defines the default logic on how to handle errors from the controller. Any errors from parsing request params will return a StatusBadRequest. Otherwise, the error code originating from the servicer will be used.

func EncodeJSONResponse

func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error

EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code

func IsZeroValue

func IsZeroValue(val interface{}) bool

IsZeroValue checks if the val is the zero-ed value.

func Logger

func Logger(inner http.Handler, name string) http.Handler

func NewRouter

func NewRouter(routers ...Router) *mux.Router

NewRouter creates a new router for any number of api routers

func ReadFormFileToTempFile

func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)

ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file

func ReadFormFilesToTempFiles

func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error)

ReadFormFilesToTempFiles reads files array data from a request form and writes it to a temporary files

type DefaultApiController

DefaultApiController binds http requests to an api service and writes the service results to the http response

type DefaultApiController struct {
    // contains filtered or unexported fields
}

func (*DefaultApiController) FilesGet

func (c *DefaultApiController) FilesGet(w http.ResponseWriter, r *http.Request)

FilesGet - get the installed files

func (*DefaultApiController) PlayerinfoGet

func (c *DefaultApiController) PlayerinfoGet(w http.ResponseWriter, r *http.Request)

PlayerinfoGet - get the player infomation

func (*DefaultApiController) Routes

func (c *DefaultApiController) Routes() Routes

Routes returns all the api routes for the DefaultApiController

func (*DefaultApiController) ServerinfoGet

func (c *DefaultApiController) ServerinfoGet(w http.ResponseWriter, r *http.Request)

ServerinfoGet - get the server information

type DefaultApiOption

DefaultApiOption for how the controller is set up.

type DefaultApiOption func(*DefaultApiController)

func WithDefaultApiErrorHandler

func WithDefaultApiErrorHandler(h ErrorHandler) DefaultApiOption

WithDefaultApiErrorHandler inject ErrorHandler into controller

type DefaultApiRouter

DefaultApiRouter defines the required methods for binding the api requests to a responses for the DefaultApi The DefaultApiRouter implementation should parse necessary information from the http request, pass the data to a DefaultApiServicer to perform the required actions, then write the service results to the http response.

type DefaultApiRouter interface {
    FilesGet(http.ResponseWriter, *http.Request)
    PlayerinfoGet(http.ResponseWriter, *http.Request)
    ServerinfoGet(http.ResponseWriter, *http.Request)
}

type DefaultApiService

DefaultApiService is a service that implements the logic for the DefaultApiServicer This service should implement the business logic for every endpoint for the DefaultApi API. Include any external packages or services that will be required by this service.

type DefaultApiService struct {
    Target string
}

func (*DefaultApiService) FilesGet

func (s *DefaultApiService) FilesGet(ctx context.Context) (ImplResponse, error)

MapsGet - get the installed mods

func (*DefaultApiService) PlayerinfoGet

func (s *DefaultApiService) PlayerinfoGet(ctx context.Context) (ImplResponse, error)

PlayerinfoGet - get the player infomation

func (*DefaultApiService) ServerinfoGet

func (s *DefaultApiService) ServerinfoGet(ctx context.Context) (ImplResponse, error)

ServerinfoGet - get the server information

type DefaultApiServicer

DefaultApiServicer defines the api actions for the DefaultApi service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can be ignored with the .openapi-generator-ignore file and updated with the logic required for the API.

type DefaultApiServicer interface {
    FilesGet(context.Context) (ImplResponse, error)
    PlayerinfoGet(context.Context) (ImplResponse, error)
    ServerinfoGet(context.Context) (ImplResponse, error)
}

func NewDefaultApiService

func NewDefaultApiService(target string) DefaultApiServicer

NewDefaultApiService creates a default api service

type ErrorHandler

ErrorHandler defines the required method for handling error. You may implement it and inject this into a controller if you would like errors to be handled differently from the DefaultErrorHandler

type ErrorHandler func(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse)

type FileNeededInner

type FileNeededInner struct {
    WillSend bool `json:"WillSend,omitempty"`

    TotalSize float32 `json:"TotalSize,omitempty"`

    FileName string `json:"FileName,omitempty"`

    MD5 []float32 `json:"MD5,omitempty"`
}

type ImplResponse

ImplResponse response defines an error code with the associated body

type ImplResponse struct {
    Code int
    Body interface{}
}

func Response

func Response(code int, body interface{}) ImplResponse

Response return a ImplResponse struct filled

type ParsingError

ParsingError indicates that an error has occurred when parsing request parameters

type ParsingError struct {
    Err error
}

func (*ParsingError) Error

func (e *ParsingError) Error() string

func (*ParsingError) Unwrap

func (e *ParsingError) Unwrap() error

type PlayerInfo

type PlayerInfo []PlayerInfoEntry

type PlayerInfoEntry

type PlayerInfoEntry struct {
    Node uint8 `json:"Node"`

    Name string `json:"Name"`

    Address string `json:"Address"`

    Team uint8 `json:"Team"`

    Skin uint8 `json:"Skin"`

    Data uint8 `json:"Data"`

    Score uint32 `json:"Score"`

    TimeInServer uint16 `json:"TimeInServer"`
}

type RequiredError

RequiredError indicates that an error has occurred when parsing request parameters

type RequiredError struct {
    Field string
}

func (*RequiredError) Error

func (e *RequiredError) Error() string

type Route

A Route defines the parameters for an api endpoint

type Route struct {
    Name        string
    Method      string
    Pattern     string
    HandlerFunc http.HandlerFunc
}

type Router

Router defines the required methods for retrieving api routes

type Router interface {
    Routes() Routes
}

func NewDefaultApiController

func NewDefaultApiController(s DefaultApiServicer, opts ...DefaultApiOption) Router

NewDefaultApiController creates a default api controller

type Routes

Routes are a collection of defined api endpoints

type Routes []Route

type ServerInfo

type ServerInfo struct {
    PacketVersion uint8 `json:"PacketVersion,omitempty"`

    Application string `json:"Application,omitempty"`

    Version uint8 `json:"Version,omitempty"`

    SubVersion uint8 `json:"SubVersion,omitempty"`

    NumberOfPlayer uint8 `json:"NumberOfPlayer,omitempty"`

    MaxPlayers uint8 `json:"MaxPlayers,omitempty"`

    GameType uint8 `json:"GameType,omitempty"`

    ModifiedGame bool `json:"ModifiedGame,omitempty"`

    CheatsEnabled bool `json:"CheatsEnabled,omitempty"`

    KartVars uint8 `json:"KartVars,omitempty"`

    FileNeededNum uint8 `json:"FileNeededNum,omitempty"`

    Time uint32 `json:"Time,omitempty"`

    LevelTime uint32 `json:"LevelTime,omitempty"`

    ServerNameRaw string `json:"ServerNameRaw,omitempty"`

    MapName string `json:"MapName,omitempty"`

    MapTitle string `json:"MapTitle,omitempty"`

    MapMD5 [16]byte `json:"MapMD5,omitempty"`

    ActNum uint8 `json:"ActNum,omitempty"`

    IsZone bool `json:"IsZone,omitempty"`

    HttpSource string `json:"HttpSource,omitempty"`

    FileNeeded []FileNeededInner `json:"FileNeeded,omitempty"`
}