/
pyo
/
updater
Обзор
Документация
Войти
/
pyo
/
updater
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
develop
pkg/server/server.go
860 строк
29 KB
ilovepitsa
restore from another repo
16 июн 2025, 13:25
16 июн 2025, 13:25
d7455bb
Код
Авторство
О чём код?
// Package server 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 server import ( "fmt" "net/http" "github.com/labstack/echo/v4" "github.com/oapi-codegen/runtime" openapi_types "github.com/oapi-codegen/runtime/types" ) // Defines values for ComponentType. const ( Executable ComponentType = "executable" Grammar ComponentType = "grammar" LanguageServer ComponentType = "languageServer" Module ComponentType = "module" Plugin ComponentType = "plugin" Scenario ComponentType = "scenario" Semantics ComponentType = "semantics" Setting ComponentType = "setting" Shell ComponentType = "shell" ) // Author defines model for Author. type Author struct { Name string `json:"name"` } // BuildOptions defines model for BuildOptions. type BuildOptions struct { CrossCompileTools *[]string `json:"crossCompileTools,omitempty"` Platforms *[]Platform `json:"platforms,omitempty"` Tools *[]string `json:"tools,omitempty"` } // ComponentDescription defines model for ComponentDescription. type ComponentDescription struct { Author Author `json:"author"` // Description Короткое описание Description *string `json:"description,omitempty"` // DisplayName Название, которое будет отображаться в списке расширений. DisplayName string `json:"displayName"` // Homepage Ссылка на описание(readme) в репозитории с исходным кодом компоненты Homepage *string `json:"homepage,omitempty"` Icon *string `json:"icon,omitempty"` // Name Название компонента. Все должно быть написано строчными буквами без пробелов. // Название должно быть уникально для всей библиотеки расширейний Name string `json:"name"` Pricing *Price `json:"pricing,omitempty"` // Publisher Идентификатор издателя Publisher string `json:"publisher"` Type ComponentType `json:"type"` } // ComponentDescriptionWithVersion defines model for ComponentDescriptionWithVersion. type ComponentDescriptionWithVersion struct { Description ComponentDescription `json:"description"` Version Version `json:"version"` } // ComponentDescriptionWithVersions defines model for ComponentDescriptionWithVersions. type ComponentDescriptionWithVersions struct { Description *ComponentDescription `json:"description,omitempty"` Version *[]Version `json:"version,omitempty"` } // ComponentDownload defines model for ComponentDownload. type ComponentDownload = openapi_types.File // ComponentDownloadInfo defines model for ComponentDownloadInfo. type ComponentDownloadInfo struct { Sha *string `json:"sha,omitempty"` Type *string `json:"type,omitempty"` } // ComponentType defines model for ComponentType. type ComponentType string // GetComponentsResponse defines model for GetComponentsResponse. type GetComponentsResponse = []ComponentDescriptionWithVersions // Platform defines model for Platform. type Platform struct { EnvVariables *[]string `json:"envVariables,omitempty"` Platforms *string `json:"platforms,omitempty"` } // Price defines model for Price. type Price struct { Amount *float32 `json:"Amount,omitempty"` } // UpdateElement defines model for UpdateElement. type UpdateElement struct { // Name Название компонента. Все должно быть написано строчными буквами без пробелов. // Название должно быть уникально для всей библиотеки расширейний Name *string `json:"name,omitempty"` // Version Должно быть совместимо с https://semver.org/ Version *string `json:"version,omitempty"` } // UpdateElements defines model for UpdateElements. type UpdateElements = []UpdateElement // Version defines model for Version. type Version struct { BuildOptions *BuildOptions `json:"buildOptions,omitempty"` DevDependencies *DevDependencies `json:"devDependencies,omitempty"` // Version Должно быть совместимо с https://semver.org/ Version *string `json:"version,omitempty"` } // DevDependence Зависимости вашей компоненты type DevDependence struct { Name string `json:"name"` Version *string `json:"version,omitempty"` } // DevDependencies defines model for devDependencies. type DevDependencies = []DevDependence // UpdErrorResponse defines model for upd.ErrorResponse. type UpdErrorResponse struct { Code int `json:"code"` Details *map[string]string `json:"details,omitempty"` } // PublishComponentMultipartBody defines parameters for PublishComponent. type PublishComponentMultipartBody struct { // Description Должен соответтствовать ComponentDescriptionWithVersion Description string `json:"description"` File openapi_types.File `json:"file"` } // PublishComponentVersionMultipartBody defines parameters for PublishComponentVersion. type PublishComponentVersionMultipartBody struct { // Description Должен соответтствовать Version Description string `json:"description"` File openapi_types.File `json:"file"` } // PutPublishNameJSONBody defines parameters for PutPublishName. type PutPublishNameJSONBody struct { Description ComponentDescription `json:"description"` } // PutPublishNameVersionMultipartBody defines parameters for PutPublishNameVersion. type PutPublishNameVersionMultipartBody struct { // Description Должен соответтствовать Version Description string `json:"description"` File openapi_types.File `json:"file"` } // GetUpdateNameVersionParams defines parameters for GetUpdateNameVersion. type GetUpdateNameVersionParams struct { Platform string `json:"platform"` } // GetUpdateNameVersionInfoParams defines parameters for GetUpdateNameVersionInfo. type GetUpdateNameVersionInfoParams struct { Platform string `json:"platform"` } // PostComponentsCheckUpdatesJSONRequestBody defines body for PostComponentsCheckUpdates for application/json ContentType. type PostComponentsCheckUpdatesJSONRequestBody = UpdateElements // PublishComponentMultipartRequestBody defines body for PublishComponent for multipart/form-data ContentType. type PublishComponentMultipartRequestBody PublishComponentMultipartBody // PublishComponentVersionMultipartRequestBody defines body for PublishComponentVersion for multipart/form-data ContentType. type PublishComponentVersionMultipartRequestBody PublishComponentVersionMultipartBody // PutPublishNameJSONRequestBody defines body for PutPublishName for application/json ContentType. type PutPublishNameJSONRequestBody PutPublishNameJSONBody // PutPublishNameVersionMultipartRequestBody defines body for PutPublishNameVersion for multipart/form-data ContentType. type PutPublishNameVersionMultipartRequestBody PutPublishNameVersionMultipartBody // ServerInterface represents all server handlers. type ServerInterface interface { // Получение списка все компонент в системе // (GET /components/) GetComponents(ctx echo.Context) error // Проверка наличия обновлений // (POST /components/check-updates) PostComponentsCheckUpdates(ctx echo.Context) error // Получение информации о конкретной компоненте // (GET /components/{name}) GetComponentsName(ctx echo.Context, name string) error // Получение доступных версий конкретной компоненты // (GET /components/{name}/versions) GetComponentsNameVersions(ctx echo.Context, name string) error // Получение информации о конкретной компоненте // (GET /components/{name}/{version}) GetComponentsNameVersion(ctx echo.Context, name string, version string) error // Загрузка компонента системы моделирования // (POST /publish) PublishComponent(ctx echo.Context) error // Загрузка новой версии компонента системы моделирования // (POST /publish/{name}) PublishComponentVersion(ctx echo.Context, name string) error // Обновление информации компонента // (PUT /publish/{name}) PutPublishName(ctx echo.Context, name string) error // Обновление компоненты // (PUT /publish/{name}/{version}) PutPublishNameVersion(ctx echo.Context, name string, version string) error // Получение определенной версии компоненты // (GET /update/{name}/{version}) GetUpdateNameVersion(ctx echo.Context, name string, version string, params GetUpdateNameVersionParams) error // Получение определенной версии компоненты // (GET /update/{name}/{version}/info) GetUpdateNameVersionInfo(ctx echo.Context, name string, version string, params GetUpdateNameVersionInfoParams) error } type EchoBinder interface { BindPathParams(c echo.Context, i any) error BindQueryParams(c echo.Context, i any) error BindBody(c echo.Context, i any) error BindHeaders(c echo.Context, i any) error } type EchoBindError struct { Path error Query error Header error Body error } func (ebe EchoBindError) IsEmpty() bool { return ebe.Path == nil && ebe.Query == nil && ebe.Header == nil && ebe.Body == nil } func (ebe EchoBindError) Error() string { s := "EchoBindError: " if ebe.Path != nil { s += ebe.Path.Error() + "; " } if ebe.Query != nil { s += ebe.Query.Error() + "; " } if ebe.Header != nil { s += ebe.Header.Error() + "; " } if ebe.Body != nil { s += ebe.Body.Error() + "; " } return s } type EchoRouteInfo struct { OperationID string IsTx bool Bind func(echo.Context, EchoBinder) (any, error) } type EchoGetComponentsParams struct { } func EchoGetComponentsBind(ctx echo.Context, binder EchoBinder) (any, error) { var ( ebe EchoBindError params EchoGetComponentsParams ) _ = params if !ebe.IsEmpty() { return nil, ebe } return params, nil } type EchoPostComponentsCheckUpdatesParams struct { Body PostComponentsCheckUpdatesJSONRequestBody } func EchoPostComponentsCheckUpdatesBind(ctx echo.Context, binder EchoBinder) (any, error) { var ( ebe EchoBindError params EchoPostComponentsCheckUpdatesParams ) _ = params ebe.Body = binder.BindBody(ctx, ¶ms.Body) if !ebe.IsEmpty() { return nil, ebe } return params, nil } type EchoGetComponentsNamePathParams struct { Name string `param:"name"` } type EchoGetComponentsNameParams struct { Path EchoGetComponentsNamePathParams } func EchoGetComponentsNameBind(ctx echo.Context, binder EchoBinder) (any, error) { var ( ebe EchoBindError params EchoGetComponentsNameParams ) _ = params ebe.Path = binder.BindPathParams(ctx, ¶ms.Path) if !ebe.IsEmpty() { return nil, ebe } return params, nil } type EchoGetComponentsNameVersionsPathParams struct { Name string `param:"name"` } type EchoGetComponentsNameVersionsParams struct { Path EchoGetComponentsNameVersionsPathParams } func EchoGetComponentsNameVersionsBind(ctx echo.Context, binder EchoBinder) (any, error) { var ( ebe EchoBindError params EchoGetComponentsNameVersionsParams ) _ = params ebe.Path = binder.BindPathParams(ctx, ¶ms.Path) if !ebe.IsEmpty() { return nil, ebe } return params, nil } type EchoGetComponentsNameVersionPathParams struct { Name string `param:"name"` Version string `param:"version"` } type EchoGetComponentsNameVersionParams struct { Path EchoGetComponentsNameVersionPathParams } func EchoGetComponentsNameVersionBind(ctx echo.Context, binder EchoBinder) (any, error) { var ( ebe EchoBindError params EchoGetComponentsNameVersionParams ) _ = params ebe.Path = binder.BindPathParams(ctx, ¶ms.Path) if !ebe.IsEmpty() { return nil, ebe } return params, nil } type EchoPublishComponentParams struct { Body PublishComponentMultipartRequestBody } func EchoPublishComponentBind(ctx echo.Context, binder EchoBinder) (any, error) { var ( ebe EchoBindError params EchoPublishComponentParams ) _ = params ebe.Body = binder.BindBody(ctx, ¶ms.Body) if !ebe.IsEmpty() { return nil, ebe } return params, nil } type EchoPublishComponentVersionPathParams struct { Name string `param:"name"` } type EchoPublishComponentVersionParams struct { Path EchoPublishComponentVersionPathParams Body PublishComponentVersionMultipartRequestBody } func EchoPublishComponentVersionBind(ctx echo.Context, binder EchoBinder) (any, error) { var ( ebe EchoBindError params EchoPublishComponentVersionParams ) _ = params ebe.Path = binder.BindPathParams(ctx, ¶ms.Path) ebe.Body = binder.BindBody(ctx, ¶ms.Body) if !ebe.IsEmpty() { return nil, ebe } return params, nil } type EchoPutPublishNamePathParams struct { Name string `param:"name"` } type EchoPutPublishNameParams struct { Path EchoPutPublishNamePathParams Body PutPublishNameJSONRequestBody } func EchoPutPublishNameBind(ctx echo.Context, binder EchoBinder) (any, error) { var ( ebe EchoBindError params EchoPutPublishNameParams ) _ = params ebe.Path = binder.BindPathParams(ctx, ¶ms.Path) ebe.Body = binder.BindBody(ctx, ¶ms.Body) if !ebe.IsEmpty() { return nil, ebe } return params, nil } type EchoPutPublishNameVersionPathParams struct { Name string `param:"name"` Version string `param:"version"` } type EchoPutPublishNameVersionParams struct { Path EchoPutPublishNameVersionPathParams Body PutPublishNameVersionMultipartRequestBody } func EchoPutPublishNameVersionBind(ctx echo.Context, binder EchoBinder) (any, error) { var ( ebe EchoBindError params EchoPutPublishNameVersionParams ) _ = params ebe.Path = binder.BindPathParams(ctx, ¶ms.Path) ebe.Body = binder.BindBody(ctx, ¶ms.Body) if !ebe.IsEmpty() { return nil, ebe } return params, nil } type EchoGetUpdateNameVersionPathParams struct { Name string `param:"name"` Version string `param:"version"` } type EchoGetUpdateNameVersionHeaderParams struct { Platform string `header:"platform"` } type EchoGetUpdateNameVersionParams struct { Path EchoGetUpdateNameVersionPathParams Header EchoGetUpdateNameVersionHeaderParams } func EchoGetUpdateNameVersionBind(ctx echo.Context, binder EchoBinder) (any, error) { var ( ebe EchoBindError params EchoGetUpdateNameVersionParams ) _ = params ebe.Path = binder.BindPathParams(ctx, ¶ms.Path) ebe.Header = binder.BindHeaders(ctx, ¶ms.Header) if !ebe.IsEmpty() { return nil, ebe } return params, nil } type EchoGetUpdateNameVersionInfoPathParams struct { Name string `param:"name"` Version string `param:"version"` } type EchoGetUpdateNameVersionInfoHeaderParams struct { Platform string `header:"platform"` } type EchoGetUpdateNameVersionInfoParams struct { Path EchoGetUpdateNameVersionInfoPathParams Header EchoGetUpdateNameVersionInfoHeaderParams } func EchoGetUpdateNameVersionInfoBind(ctx echo.Context, binder EchoBinder) (any, error) { var ( ebe EchoBindError params EchoGetUpdateNameVersionInfoParams ) _ = params ebe.Path = binder.BindPathParams(ctx, ¶ms.Path) ebe.Header = binder.BindHeaders(ctx, ¶ms.Header) if !ebe.IsEmpty() { return nil, ebe } return params, nil } var EchoRoutes = map[string]EchoRouteInfo{ "GET;/components/": { OperationID: "GetComponents", Bind: EchoGetComponentsBind, IsTx: false, }, "POST;/components/check-updates": { OperationID: "PostComponentsCheckUpdates", Bind: EchoPostComponentsCheckUpdatesBind, IsTx: false, }, "GET;/components/:name": { OperationID: "GetComponentsName", Bind: EchoGetComponentsNameBind, IsTx: false, }, "GET;/components/:name/versions": { OperationID: "GetComponentsNameVersions", Bind: EchoGetComponentsNameVersionsBind, IsTx: false, }, "GET;/components/:name/:version": { OperationID: "GetComponentsNameVersion", Bind: EchoGetComponentsNameVersionBind, IsTx: false, }, "POST;/publish": { OperationID: "PublishComponent", Bind: EchoPublishComponentBind, IsTx: false, }, "POST;/publish/:name": { OperationID: "PublishComponentVersion", Bind: EchoPublishComponentVersionBind, IsTx: false, }, "PUT;/publish/:name": { OperationID: "PutPublishName", Bind: EchoPutPublishNameBind, IsTx: false, }, "PUT;/publish/:name/:version": { OperationID: "PutPublishNameVersion", Bind: EchoPutPublishNameVersionBind, IsTx: false, }, "GET;/update/:name/:version": { OperationID: "GetUpdateNameVersion", Bind: EchoGetUpdateNameVersionBind, IsTx: false, }, "GET;/update/:name/:version/info": { OperationID: "GetUpdateNameVersionInfo", Bind: EchoGetUpdateNameVersionInfoBind, IsTx: false, }, } // ServerInterfaceWrapper converts echo contexts to parameters. type ServerInterfaceWrapper struct { Handler ServerInterface } // GetComponents converts echo context to params. func (w *ServerInterfaceWrapper) GetComponents(ctx echo.Context) error { var err error // Invoke the callback with all the unmarshaled arguments err = w.Handler.GetComponents(ctx) return err } // PostComponentsCheckUpdates converts echo context to params. func (w *ServerInterfaceWrapper) PostComponentsCheckUpdates(ctx echo.Context) error { var err error // Invoke the callback with all the unmarshaled arguments err = w.Handler.PostComponentsCheckUpdates(ctx) return err } // GetComponentsName converts echo context to params. func (w *ServerInterfaceWrapper) GetComponentsName(ctx echo.Context) error { var err error // ------------- Path parameter "name" ------------- var name string err = runtime.BindStyledParameterWithOptions("simple", "name", ctx.Param("name"), &name, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) } // Invoke the callback with all the unmarshaled arguments err = w.Handler.GetComponentsName(ctx, name) return err } // GetComponentsNameVersions converts echo context to params. func (w *ServerInterfaceWrapper) GetComponentsNameVersions(ctx echo.Context) error { var err error // ------------- Path parameter "name" ------------- var name string err = runtime.BindStyledParameterWithOptions("simple", "name", ctx.Param("name"), &name, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) } // Invoke the callback with all the unmarshaled arguments err = w.Handler.GetComponentsNameVersions(ctx, name) return err } // GetComponentsNameVersion converts echo context to params. func (w *ServerInterfaceWrapper) GetComponentsNameVersion(ctx echo.Context) error { var err error // ------------- Path parameter "name" ------------- var name string err = runtime.BindStyledParameterWithOptions("simple", "name", ctx.Param("name"), &name, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) } // ------------- Path parameter "version" ------------- var version string err = runtime.BindStyledParameterWithOptions("simple", "version", ctx.Param("version"), &version, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter version: %s", err)) } // Invoke the callback with all the unmarshaled arguments err = w.Handler.GetComponentsNameVersion(ctx, name, version) return err } // PublishComponent converts echo context to params. func (w *ServerInterfaceWrapper) PublishComponent(ctx echo.Context) error { var err error // Invoke the callback with all the unmarshaled arguments err = w.Handler.PublishComponent(ctx) return err } // PublishComponentVersion converts echo context to params. func (w *ServerInterfaceWrapper) PublishComponentVersion(ctx echo.Context) error { var err error // ------------- Path parameter "name" ------------- var name string err = runtime.BindStyledParameterWithOptions("simple", "name", ctx.Param("name"), &name, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) } // Invoke the callback with all the unmarshaled arguments err = w.Handler.PublishComponentVersion(ctx, name) return err } // PutPublishName converts echo context to params. func (w *ServerInterfaceWrapper) PutPublishName(ctx echo.Context) error { var err error // ------------- Path parameter "name" ------------- var name string err = runtime.BindStyledParameterWithOptions("simple", "name", ctx.Param("name"), &name, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) } // Invoke the callback with all the unmarshaled arguments err = w.Handler.PutPublishName(ctx, name) return err } // PutPublishNameVersion converts echo context to params. func (w *ServerInterfaceWrapper) PutPublishNameVersion(ctx echo.Context) error { var err error // ------------- Path parameter "name" ------------- var name string err = runtime.BindStyledParameterWithOptions("simple", "name", ctx.Param("name"), &name, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) } // ------------- Path parameter "version" ------------- var version string err = runtime.BindStyledParameterWithOptions("simple", "version", ctx.Param("version"), &version, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter version: %s", err)) } // Invoke the callback with all the unmarshaled arguments err = w.Handler.PutPublishNameVersion(ctx, name, version) return err } // GetUpdateNameVersion converts echo context to params. func (w *ServerInterfaceWrapper) GetUpdateNameVersion(ctx echo.Context) error { var err error // ------------- Path parameter "name" ------------- var name string err = runtime.BindStyledParameterWithOptions("simple", "name", ctx.Param("name"), &name, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) } // ------------- Path parameter "version" ------------- var version string err = runtime.BindStyledParameterWithOptions("simple", "version", ctx.Param("version"), &version, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter version: %s", err)) } // Parameter object where we will unmarshal all parameters from the context var params GetUpdateNameVersionParams headers := ctx.Request().Header // ------------- Required header parameter "platform" ------------- if valueList, found := headers[http.CanonicalHeaderKey("platform")]; found { var Platform string n := len(valueList) if n != 1 { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Expected one value for platform, got %d", n)) } err = runtime.BindStyledParameterWithOptions("simple", "platform", valueList[0], &Platform, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter platform: %s", err)) } params.Platform = Platform } else { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Header parameter platform is required, but not found")) } // Invoke the callback with all the unmarshaled arguments err = w.Handler.GetUpdateNameVersion(ctx, name, version, params) return err } // GetUpdateNameVersionInfo converts echo context to params. func (w *ServerInterfaceWrapper) GetUpdateNameVersionInfo(ctx echo.Context) error { var err error // ------------- Path parameter "name" ------------- var name string err = runtime.BindStyledParameterWithOptions("simple", "name", ctx.Param("name"), &name, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err)) } // ------------- Path parameter "version" ------------- var version string err = runtime.BindStyledParameterWithOptions("simple", "version", ctx.Param("version"), &version, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter version: %s", err)) } // Parameter object where we will unmarshal all parameters from the context var params GetUpdateNameVersionInfoParams headers := ctx.Request().Header // ------------- Required header parameter "platform" ------------- if valueList, found := headers[http.CanonicalHeaderKey("platform")]; found { var Platform string n := len(valueList) if n != 1 { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Expected one value for platform, got %d", n)) } err = runtime.BindStyledParameterWithOptions("simple", "platform", valueList[0], &Platform, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: true}) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter platform: %s", err)) } params.Platform = Platform } else { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Header parameter platform is required, but not found")) } // Invoke the callback with all the unmarshaled arguments err = w.Handler.GetUpdateNameVersionInfo(ctx, name, version, params) return err } // This is a simple interface which specifies echo.Route addition functions which // are present on both echo.Echo and echo.Group, since we want to allow using // either of them for path registration type EchoRouter interface { CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route } // RegisterHandlers adds each server route to the EchoRouter. func RegisterHandlers(router EchoRouter, si ServerInterface) { RegisterHandlersWithBaseURL(router, si, "") } // Registers handlers, and prepends BaseURL to the paths, so that the paths // can be served under a prefix. func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) { wrapper := ServerInterfaceWrapper{ Handler: si, } router.GET(baseURL+"/components/", wrapper.GetComponents) router.POST(baseURL+"/components/check-updates", wrapper.PostComponentsCheckUpdates) router.GET(baseURL+"/components/:name", wrapper.GetComponentsName) router.GET(baseURL+"/components/:name/versions", wrapper.GetComponentsNameVersions) router.GET(baseURL+"/components/:name/:version", wrapper.GetComponentsNameVersion) router.POST(baseURL+"/publish", wrapper.PublishComponent) router.POST(baseURL+"/publish/:name", wrapper.PublishComponentVersion) router.PUT(baseURL+"/publish/:name", wrapper.PutPublishName) router.PUT(baseURL+"/publish/:name/:version", wrapper.PutPublishNameVersion) router.GET(baseURL+"/update/:name/:version", wrapper.GetUpdateNameVersion) router.GET(baseURL+"/update/:name/:version/info", wrapper.GetUpdateNameVersionInfo) }