Documentation
¶
Index ¶
- Constants
- Variables
- func HandleByteResponse(w http.ResponseWriter, r *http.Request, status int, mime string, data []byte)
- func HandleErrorResponse(w http.ResponseWriter, r *http.Request, err error)
- func HandleHealthyResponse(w http.ResponseWriter, r *http.Request)
- func HandleJsonResponse(w http.ResponseWriter, r *http.Request, status int, data interface{})
- func NewBadRequestError(err error, detail string, args ...any) error
- func NewDefaultHandlerService(servedRepo model.RepoSpec) (*defaultHandlerService, error)
- func NewHttpHandler(si server.ServerInterface, mws []server.MiddlewareFunc) http.Handler
- func NewNotFoundError(err error, detail string, args ...any) error
- func NewServiceUnavailableError(err error, detail string) error
- func NewUnauthorizedError(err error, detail string, args ...any) error
- func WithLogAfterRequestProcessing(handler http.Handler) http.Handler
- func WithRequestLogger(handler http.Handler) http.Handler
- type BaseHttpError
- type HandlerService
- type Mapper
- func (m *Mapper) GetAttachmentListEntry(ref model.AttachmentContainerRef, a model.Attachment, foundInRepo string) server.AttachmentsListEntry
- func (m *Mapper) GetAttachmentsList(ref model.AttachmentContainerRef, container model.AttachmentContainer, ...) server.AttachmentsList
- func (m *Mapper) GetInventoryData(entries []model.FoundEntry) []server.InventoryEntry
- func (m *Mapper) GetInventoryEntry(entry model.FoundEntry) server.InventoryEntry
- func (m *Mapper) GetInventoryEntryVersion(version model.FoundVersion) server.InventoryEntryVersion
- func (m *Mapper) GetInventoryEntryVersions(versions []model.FoundVersion) []server.InventoryEntryVersion
- func (m *Mapper) GetInventoryMeta(res model.SearchResult) server.Meta
- type TmcHandler
- func (h *TmcHandler) DeleteTMNameAttachment(w http.ResponseWriter, r *http.Request, tmName server.TMName, ...)
- func (h *TmcHandler) DeleteThingModelAttachmentByName(w http.ResponseWriter, r *http.Request, tmID server.TMID, ...)
- func (h *TmcHandler) DeleteThingModelById(w http.ResponseWriter, r *http.Request, tmID string, ...)
- func (h *TmcHandler) GetAuthors(w http.ResponseWriter, r *http.Request, params server.GetAuthorsParams)
- func (h *TmcHandler) GetCompletions(w http.ResponseWriter, r *http.Request, params server.GetCompletionsParams)
- func (h *TmcHandler) GetHealth(w http.ResponseWriter, r *http.Request)
- func (h *TmcHandler) GetHealthLive(w http.ResponseWriter, r *http.Request)
- func (h *TmcHandler) GetHealthReady(w http.ResponseWriter, r *http.Request)
- func (h *TmcHandler) GetHealthStartup(w http.ResponseWriter, r *http.Request)
- func (h *TmcHandler) GetInfo(w http.ResponseWriter, r *http.Request)
- func (h *TmcHandler) GetInventory(w http.ResponseWriter, r *http.Request, params server.GetInventoryParams)
- func (h *TmcHandler) GetInventoryByFetchName(w http.ResponseWriter, r *http.Request, fetchName server.FetchName, ...)
- func (h *TmcHandler) GetInventoryByID(w http.ResponseWriter, r *http.Request, tmID server.TMID, ...)
- func (h *TmcHandler) GetInventoryByName(w http.ResponseWriter, r *http.Request, tmName string, ...)
- func (h *TmcHandler) GetManufacturers(w http.ResponseWriter, r *http.Request, params server.GetManufacturersParams)
- func (h *TmcHandler) GetMpns(w http.ResponseWriter, r *http.Request, params server.GetMpnsParams)
- func (h *TmcHandler) GetRepos(w http.ResponseWriter, r *http.Request)
- func (h *TmcHandler) GetTMNameAttachment(w http.ResponseWriter, r *http.Request, tmName server.TMName, ...)
- func (h *TmcHandler) GetThingModelAttachmentByName(w http.ResponseWriter, r *http.Request, tmid, attachmentFileName string, ...)
- func (h *TmcHandler) GetThingModelByFetchName(w http.ResponseWriter, r *http.Request, fetchName server.FetchName, ...)
- func (h *TmcHandler) GetThingModelById(w http.ResponseWriter, r *http.Request, id string, ...)
- func (h *TmcHandler) ImportThingModel(w http.ResponseWriter, r *http.Request, p server.ImportThingModelParams)
- func (h *TmcHandler) PutTMIDAttachment(w http.ResponseWriter, r *http.Request, tmID string, attachmentFileName string, ...)
- func (h *TmcHandler) PutTMNameAttachment(w http.ResponseWriter, r *http.Request, tmName server.TMName, ...)
- type TmcHandlerOptions
Constants ¶
const ( Error400Title = "Bad Request" Error401Title = "Unauthorized" Error404Title = "Not Found" Error409Title = "Conflict" Error503Title = "Service Unavailable" Error500Title = "Internal Server Error" Error500Detail = "An unhandled error has occurred. Try again later. If it is a bug we already recorded it. Retrying will most likely not help" Error502Title = "Bad Gateway" Error502Detail = "An upstream Thing Model repository returned an error" ErrorRepoAmbiguousDetail = "Repository ambiguous. Repeat the request with the 'repo' query parameter" ErrorSearchIndexNotFoundDetail = "" /* 161-byte string literal not displayed */ HeaderAuthorization = "Authorization" HeaderContentType = "Content-Type" HeaderCacheControl = "Cache-Control" HeaderXContentTypeOptions = "X-Content-Type-Options" MimeText = "text/plain" MimeJSON = "application/json" MimeTMJSON = "application/tm+json" MimeOctetStream = "application/octet-stream" MimeProblemJSON = "application/problem+json" NoSniff = "nosniff" NoCache = "no-cache, no-store, max-age=0, must-revalidate" )
Variables ¶
var ErrIncompatibleParameters = errors.New("request parameters incompatible")
Functions ¶
func HandleByteResponse ¶
func HandleErrorResponse ¶
func HandleErrorResponse(w http.ResponseWriter, r *http.Request, err error)
func HandleHealthyResponse ¶
func HandleHealthyResponse(w http.ResponseWriter, r *http.Request)
func HandleJsonResponse ¶
func HandleJsonResponse(w http.ResponseWriter, r *http.Request, status int, data interface{})
func NewHttpHandler ¶
func NewHttpHandler(si server.ServerInterface, mws []server.MiddlewareFunc) http.Handler
func WithLogAfterRequestProcessing ¶ added in v0.1.3
Types ¶
type BaseHttpError ¶
func (*BaseHttpError) Error ¶
func (e *BaseHttpError) Error() string
func (*BaseHttpError) Unwrap ¶
func (e *BaseHttpError) Unwrap() error
type HandlerService ¶
type HandlerService interface {
ListInventory(ctx context.Context, repo string, filters *model.Filters) (*model.SearchResult, error)
SearchInventory(ctx context.Context, repo, query string) (*model.SearchResult, error)
ListAuthors(ctx context.Context, filters *model.Filters) ([]string, error)
ListManufacturers(ctx context.Context, filters *model.Filters) ([]string, error)
ListMpns(ctx context.Context, filters *model.Filters) ([]string, error)
FindInventoryEntries(ctx context.Context, repo string, name string) ([]model.FoundEntry, error)
FetchThingModel(ctx context.Context, repo, tmID string, restoreId bool) ([]byte, error)
FetchLatestThingModel(ctx context.Context, repo, fetchName string, restoreId bool) ([]byte, error)
ImportThingModel(ctx context.Context, repo string, file []byte, opts repos.ImportOptions) (repos.ImportResult, error)
DeleteThingModel(ctx context.Context, repo string, tmID string) error
CheckHealth(ctx context.Context) error
CheckHealthLive(ctx context.Context) error
CheckHealthReady(ctx context.Context) error
CheckHealthStartup(ctx context.Context) error
GetCompletions(ctx context.Context, kind string, args []string, toComplete string) ([]string, error)
GetTMMetadata(ctx context.Context, repo string, tmID string) ([]model.FoundVersion, error)
GetLatestTMMetadata(ctx context.Context, repo string, fetchName string) (model.FoundVersion, error)
FetchAttachment(ctx context.Context, repo string, ref model.AttachmentContainerRef, attachmentFileName string, concat bool) ([]byte, error)
ImportAttachment(ctx context.Context, repo string, ref model.AttachmentContainerRef, attachmentFileName string, content []byte, contentType string, force bool) error
DeleteAttachment(ctx context.Context, repo string, ref model.AttachmentContainerRef, attachmentFileName string) error
ListRepos(ctx context.Context) ([]model.RepoDescription, error)
}
type Mapper ¶
func (*Mapper) GetAttachmentListEntry ¶ added in v0.1.3
func (m *Mapper) GetAttachmentListEntry(ref model.AttachmentContainerRef, a model.Attachment, foundInRepo string) server.AttachmentsListEntry
func (*Mapper) GetAttachmentsList ¶ added in v0.1.3
func (m *Mapper) GetAttachmentsList(ref model.AttachmentContainerRef, container model.AttachmentContainer, foundInRepo string) server.AttachmentsList
func (*Mapper) GetInventoryData ¶
func (m *Mapper) GetInventoryData(entries []model.FoundEntry) []server.InventoryEntry
func (*Mapper) GetInventoryEntry ¶
func (m *Mapper) GetInventoryEntry(entry model.FoundEntry) server.InventoryEntry
func (*Mapper) GetInventoryEntryVersion ¶
func (m *Mapper) GetInventoryEntryVersion(version model.FoundVersion) server.InventoryEntryVersion
func (*Mapper) GetInventoryEntryVersions ¶
func (m *Mapper) GetInventoryEntryVersions(versions []model.FoundVersion) []server.InventoryEntryVersion
func (*Mapper) GetInventoryMeta ¶
func (m *Mapper) GetInventoryMeta(res model.SearchResult) server.Meta
type TmcHandler ¶
type TmcHandler struct {
Service HandlerService
Options TmcHandlerOptions
}
func NewTmcHandler ¶
func NewTmcHandler(handlerService HandlerService, options TmcHandlerOptions) *TmcHandler
func (*TmcHandler) DeleteTMNameAttachment ¶ added in v0.1.3
func (h *TmcHandler) DeleteTMNameAttachment(w http.ResponseWriter, r *http.Request, tmName server.TMName, attachmentFileName server.AttachmentFileName, params server.DeleteTMNameAttachmentParams)
func (*TmcHandler) DeleteThingModelAttachmentByName ¶ added in v0.1.3
func (h *TmcHandler) DeleteThingModelAttachmentByName(w http.ResponseWriter, r *http.Request, tmID server.TMID, attachmentFileName string, params server.DeleteThingModelAttachmentByNameParams)
func (*TmcHandler) DeleteThingModelById ¶
func (h *TmcHandler) DeleteThingModelById(w http.ResponseWriter, r *http.Request, tmID string, params server.DeleteThingModelByIdParams)
DeleteThingModelById Delete a Thing Model by ID (DELETE /thing-models/{id})
func (*TmcHandler) GetAuthors ¶
func (h *TmcHandler) GetAuthors(w http.ResponseWriter, r *http.Request, params server.GetAuthorsParams)
func (*TmcHandler) GetCompletions ¶
func (h *TmcHandler) GetCompletions(w http.ResponseWriter, r *http.Request, params server.GetCompletionsParams)
func (*TmcHandler) GetHealth ¶
func (h *TmcHandler) GetHealth(w http.ResponseWriter, r *http.Request)
GetHealth Get the overall health of the service (GET /healthz)
func (*TmcHandler) GetHealthLive ¶
func (h *TmcHandler) GetHealthLive(w http.ResponseWriter, r *http.Request)
GetHealthLive Returns the liveness of the service (GET /healthz/live)
func (*TmcHandler) GetHealthReady ¶
func (h *TmcHandler) GetHealthReady(w http.ResponseWriter, r *http.Request)
GetHealthReady Returns the readiness of the service (GET /healthz/ready)
func (*TmcHandler) GetHealthStartup ¶
func (h *TmcHandler) GetHealthStartup(w http.ResponseWriter, r *http.Request)
GetHealthStartup Returns whether the service is initialized (GET /healthz/startup)
func (*TmcHandler) GetInfo ¶ added in v0.1.3
func (h *TmcHandler) GetInfo(w http.ResponseWriter, r *http.Request)
GetInfo Returns some static information about the Thing Model Catalog API (GET /info)
func (*TmcHandler) GetInventory ¶
func (h *TmcHandler) GetInventory(w http.ResponseWriter, r *http.Request, params server.GetInventoryParams)
GetInventory returns the inventory of the catalog (GET /inventory)
func (*TmcHandler) GetInventoryByFetchName ¶
func (h *TmcHandler) GetInventoryByFetchName(w http.ResponseWriter, r *http.Request, fetchName server.FetchName, params server.GetInventoryByFetchNameParams)
GetInventoryByFetchName Get the metadata of the most recent TM version matching the name (GET /inventory/.latest/{fetchName})
func (*TmcHandler) GetInventoryByID ¶
func (h *TmcHandler) GetInventoryByID(w http.ResponseWriter, r *http.Request, tmID server.TMID, params server.GetInventoryByIDParams)
GetInventoryByID returns the metadata of a single TM by ID (GET /inventory/{tmID})
func (*TmcHandler) GetInventoryByName ¶
func (h *TmcHandler) GetInventoryByName(w http.ResponseWriter, r *http.Request, tmName string, params server.GetInventoryByNameParams)
GetInventoryByName Get an inventory entry by inventory name (GET /inventory/.tmName/{tmName})
func (*TmcHandler) GetManufacturers ¶
func (h *TmcHandler) GetManufacturers(w http.ResponseWriter, r *http.Request, params server.GetManufacturersParams)
func (*TmcHandler) GetMpns ¶
func (h *TmcHandler) GetMpns(w http.ResponseWriter, r *http.Request, params server.GetMpnsParams)
func (*TmcHandler) GetRepos ¶
func (h *TmcHandler) GetRepos(w http.ResponseWriter, r *http.Request)
func (*TmcHandler) GetTMNameAttachment ¶ added in v0.1.3
func (h *TmcHandler) GetTMNameAttachment(w http.ResponseWriter, r *http.Request, tmName server.TMName, attachmentFileName server.AttachmentFileName, params server.GetTMNameAttachmentParams)
func (*TmcHandler) GetThingModelAttachmentByName ¶ added in v0.1.3
func (h *TmcHandler) GetThingModelAttachmentByName(w http.ResponseWriter, r *http.Request, tmid, attachmentFileName string, params server.GetThingModelAttachmentByNameParams)
func (*TmcHandler) GetThingModelByFetchName ¶
func (h *TmcHandler) GetThingModelByFetchName(w http.ResponseWriter, r *http.Request, fetchName server.FetchName, params server.GetThingModelByFetchNameParams)
GetThingModelByFetchName Get the content of a Thing Model by fetch name (GET /thing-models/.latest/{fetchName}
func (*TmcHandler) GetThingModelById ¶
func (h *TmcHandler) GetThingModelById(w http.ResponseWriter, r *http.Request, id string, params server.GetThingModelByIdParams)
GetThingModelById Get the content of a Thing Model by its ID (GET /thing-models/{id})
func (*TmcHandler) ImportThingModel ¶
func (h *TmcHandler) ImportThingModel(w http.ResponseWriter, r *http.Request, p server.ImportThingModelParams)
func (*TmcHandler) PutTMIDAttachment ¶ added in v0.1.3
func (h *TmcHandler) PutTMIDAttachment(w http.ResponseWriter, r *http.Request, tmID string, attachmentFileName string, params server.PutTMIDAttachmentParams)
func (*TmcHandler) PutTMNameAttachment ¶ added in v0.1.3
func (h *TmcHandler) PutTMNameAttachment(w http.ResponseWriter, r *http.Request, tmName server.TMName, attachmentFileName server.AttachmentFileName, params server.PutTMNameAttachmentParams)
type TmcHandlerOptions ¶
type TmcHandlerOptions struct {
UrlContextRoot string
}