Documentation ¶
Index ¶
- Variables
- func AssertPathRequired(obj Path) error
- func AssertPointRequired(obj Point) error
- func AssertRecurseInterfaceRequired(obj interface{}, callback func(interface{}) error) error
- func AssertRecursePathRequired(objSlice interface{}) error
- func AssertRecursePointRequired(objSlice interface{}) error
- func AssertRecurseRouteRequestRequired(objSlice interface{}) error
- func AssertRecurseRouteResultRequired(objSlice interface{}) error
- func AssertRecurseValueRequired(value reflect.Value, callback func(interface{}) error) error
- func AssertRouteRequestRequired(obj RouteRequest) error
- func AssertRouteResultRequired(obj RouteResult) 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
- type DefaultApiOption
- type DefaultApiRouter
- type DefaultApiService
- type DefaultApiServicer
- type ErrorHandler
- type ImplResponse
- type ParsingError
- type Path
- type Point
- type RequiredError
- type Route
- type RouteRequest
- type RouteResult
- type Router
- type Routes
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTypeAssertionError is thrown when type an interface does not match the asserted type ErrTypeAssertionError = errors.New("unable to assert type") )
Functions ¶
func AssertPathRequired ¶
AssertPathRequired checks if the required fields are not zero-ed
func AssertPointRequired ¶
AssertPointRequired checks if the required fields are not zero-ed
func AssertRecurseInterfaceRequired ¶
AssertInterfaceRequired recursively checks each struct in a slice against the callback. This method traverse nested slices in a preorder fashion.
func AssertRecursePathRequired ¶
func AssertRecursePathRequired(objSlice interface{}) error
AssertRecursePathRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Path (e.g. [][]Path), otherwise ErrTypeAssertionError is thrown.
func AssertRecursePointRequired ¶
func AssertRecursePointRequired(objSlice interface{}) error
AssertRecursePointRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Point (e.g. [][]Point), otherwise ErrTypeAssertionError is thrown.
func AssertRecurseRouteRequestRequired ¶
func AssertRecurseRouteRequestRequired(objSlice interface{}) error
AssertRecurseRouteRequestRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of RouteRequest (e.g. [][]RouteRequest), otherwise ErrTypeAssertionError is thrown.
func AssertRecurseRouteResultRequired ¶
func AssertRecurseRouteResultRequired(objSlice interface{}) error
AssertRecurseRouteResultRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of RouteResult (e.g. [][]RouteResult), otherwise ErrTypeAssertionError is thrown.
func AssertRecurseValueRequired ¶
AssertNestedValueRequired checks each struct in the nested slice against the callback. This method traverse nested slices in a preorder fashion.
func AssertRouteRequestRequired ¶
func AssertRouteRequestRequired(obj RouteRequest) error
AssertRouteRequestRequired checks if the required fields are not zero-ed
func AssertRouteResultRequired ¶
func AssertRouteResultRequired(obj RouteResult) error
AssertRouteResultRequired 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 ReadFormFileToTempFile ¶
ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file
Types ¶
type DefaultApiController ¶
type DefaultApiController struct {
// contains filtered or unexported fields
}
DefaultApiController binds http requests to an api service and writes the service results to the http response
func (*DefaultApiController) ComputeRoute ¶
func (c *DefaultApiController) ComputeRoute(w http.ResponseWriter, r *http.Request)
ComputeRoute - Compute a new route
func (*DefaultApiController) Routes ¶
func (c *DefaultApiController) Routes() Routes
Routes returns all of the api route for the DefaultApiController
type DefaultApiOption ¶
type DefaultApiOption func(*DefaultApiController)
DefaultApiOption for how the controller is set up.
func WithDefaultApiErrorHandler ¶
func WithDefaultApiErrorHandler(h ErrorHandler) DefaultApiOption
WithDefaultApiErrorHandler inject ErrorHandler into controller
type DefaultApiRouter ¶
type DefaultApiRouter interface {
ComputeRoute(http.ResponseWriter, *http.Request)
}
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 DefaultApiService ¶
type DefaultApiService struct {
// contains filtered or unexported fields
}
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.
func (*DefaultApiService) ComputeRoute ¶
func (s *DefaultApiService) ComputeRoute(ctx context.Context, routeRequest RouteRequest) (ImplResponse, error)
ComputeRoute - Compute a new route
type DefaultApiServicer ¶
type DefaultApiServicer interface {
ComputeRoute(context.Context, RouteRequest) (ImplResponse, error)
}
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 ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
func NewDefaultApiService ¶
func NewDefaultApiService(graphFile string) DefaultApiServicer
NewDefaultApiService creates a default api service
type ErrorHandler ¶
type ErrorHandler func(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse)
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 ImplResponse ¶
type ImplResponse struct { Code int Body interface{} }
Implementation response defines an error code with the associated body
func Response ¶
func Response(code int, body interface{}) ImplResponse
Response return a ImplResponse struct filled
type ParsingError ¶
type ParsingError struct {
Err error
}
ParsingError indicates that an error has occurred when parsing request parameters
func (*ParsingError) Error ¶
func (e *ParsingError) Error() string
func (*ParsingError) Unwrap ¶
func (e *ParsingError) Unwrap() error
type Path ¶
type Path struct { // A path is an ordered list of points. Waypoints []Point `json:"waypoints"` // unit meters Length int32 `json:"length"` }
Path - A path is described by sequence of points as well as its total length.
type Point ¶
type Point struct { // unit degree Lat float32 `json:"lat"` // unit degree Lon float32 `json:"lon"` }
Point - Object representation of a point in the Geographic Coordinate System (GCS).
type RequiredError ¶
type RequiredError struct {
Field string
}
RequiredError indicates that an error has occurred when parsing request parameters
func (*RequiredError) Error ¶
func (e *RequiredError) Error() string
type Route ¶
type Route struct { Name string Method string Pattern string HandlerFunc http.HandlerFunc }
A Route defines the parameters for an api endpoint
type RouteRequest ¶
RouteRequest - Request a route from a origin to a destination.
type RouteResult ¶
type Router ¶
type Router interface {
Routes() Routes
}
Router defines the required methods for retrieving api routes
func NewDefaultApiController ¶
func NewDefaultApiController(s DefaultApiServicer, opts ...DefaultApiOption) Router
NewDefaultApiController creates a default api controller