blob: 79f5f62ddfa0fad09c4fdde4796075ed43e2be0f [file] [log] [blame]
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package http_handlers
import (
"net/http"
"github.com/apache/dubbo-kubernetes/pkg/bufman/controllers"
registryv1alpha1 "github.com/apache/dubbo-kubernetes/pkg/bufman/gen/proto/go/registry/v1alpha1"
"github.com/gin-gonic/gin"
)
type docGroup struct {
docController *controllers.DocController
}
var DocGroup = &docGroup{
docController: controllers.NewDocController(),
}
func (group *docGroup) GetSourceDirectoryInfo(c *gin.Context) {
// 绑定参数
req := &registryv1alpha1.GetSourceDirectoryInfoRequest{}
bindErr := c.ShouldBindUri(req)
if bindErr != nil {
c.JSON(http.StatusBadRequest, NewHTTPResponse(bindErr))
return
}
resp, err := group.docController.GetSourceDirectoryInfo(c, req)
if err != nil {
c.JSON(http.StatusInternalServerError, NewHTTPResponse(err))
}
// 正常返回
c.JSON(http.StatusOK, NewHTTPResponse(resp))
}
func (group *docGroup) GetSourceFile(c *gin.Context) {
// 绑定参数
req := &registryv1alpha1.GetSourceFileRequest{}
bindErr := c.ShouldBindUri(req)
if bindErr != nil {
c.JSON(http.StatusBadRequest, NewHTTPResponse(bindErr))
return
}
resp, err := group.docController.GetSourceFile(c, req)
if err != nil {
c.JSON(http.StatusInternalServerError, NewHTTPResponse(err))
}
// 正常返回
c.JSON(http.StatusOK, NewHTTPResponse(resp))
}
func (group *docGroup) GetModulePackages(c *gin.Context) {
// 绑定参数
req := &registryv1alpha1.GetModulePackagesRequest{}
bindErr := c.ShouldBindUri(req)
if bindErr != nil {
c.JSON(http.StatusBadRequest, NewHTTPResponse(bindErr))
return
}
resp, err := group.docController.GetModulePackages(c, req)
if err != nil {
c.JSON(http.StatusInternalServerError, NewHTTPResponse(err))
}
// 正常返回
c.JSON(http.StatusOK, NewHTTPResponse(resp))
}
func (group *docGroup) GetModuleDocumentation(c *gin.Context) {
// 绑定参数
req := &registryv1alpha1.GetModuleDocumentationRequest{}
bindErr := c.ShouldBindUri(req)
if bindErr != nil {
c.JSON(http.StatusBadRequest, NewHTTPResponse(bindErr))
return
}
resp, err := group.docController.GetModuleDocumentation(c, req)
if err != nil {
c.JSON(http.StatusInternalServerError, NewHTTPResponse(err))
}
// 正常返回
c.JSON(http.StatusOK, NewHTTPResponse(resp))
}
func (group *docGroup) GetPackageDocumentation(c *gin.Context) {
// 绑定参数
req := &registryv1alpha1.GetPackageDocumentationRequest{}
bindErr := c.ShouldBindUri(req)
if bindErr != nil {
c.JSON(http.StatusBadRequest, NewHTTPResponse(bindErr))
return
}
resp, err := group.docController.GetPackageDocumentation(c, req)
if err != nil {
c.JSON(http.StatusInternalServerError, NewHTTPResponse(err))
}
// 正常返回
c.JSON(http.StatusOK, NewHTTPResponse(resp))
}