api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.

Package api provides bindings to interact with the anilistarr API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

Types

type ChiServerOptions

type ChiServerOptions struct {
	BaseURL          string
	BaseRouter       chi.Router
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type CustomList

type CustomList = []struct {
	TvdbID *float32 `json:"TvdbID,omitempty"`
}

CustomList defines model for CustomList.

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type ServerInterface

type ServerInterface interface {
	// (GET /user/{name}/id)
	GetUserID(w http.ResponseWriter, r *http.Request, name string)

	// (GET /user/{name}/media)
	GetUserMedia(w http.ResponseWriter, r *http.Request, name string)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) GetUserID

func (siw *ServerInterfaceWrapper) GetUserID(w http.ResponseWriter, r *http.Request)

GetUserID operation middleware

func (*ServerInterfaceWrapper) GetUserMedia

func (siw *ServerInterfaceWrapper) GetUserMedia(w http.ResponseWriter, r *http.Request)

GetUserMedia operation middleware

type Service added in v0.3.0

type Service struct {
	Unimplemented

	MediaLister usecases.MediaLister
}

Service implements handlers to serve media lister as a REST API.

func (*Service) GetUserID added in v0.3.0

func (service *Service) GetUserID(w http.ResponseWriter, r *http.Request, name string)

GetUserID retrieves an user ID for a given name. Responds with:

  • 200 + plain-text ID + headers on success
  • 404 if media lister cannot find the user
  • 500 for any other errors

func (*Service) GetUserMedia added in v0.3.0

func (service *Service) GetUserMedia(w http.ResponseWriter, r *http.Request, name string)

GetUserMedia retrieves media information from an user. Returns 200 on success with a marshaled [entities.CustomList] as JSON or a 502 otherwise.

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type Unimplemented

type Unimplemented struct{}

func (Unimplemented) GetUserID

func (_ Unimplemented) GetUserID(w http.ResponseWriter, r *http.Request, name string)

(GET /user/{name}/id)

func (Unimplemented) GetUserMedia

func (_ Unimplemented) GetUserMedia(w http.ResponseWriter, r *http.Request, name string)

(GET /user/{name}/media)

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

Jump to

Keyboard shortcuts

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