-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtemplate_raw.go
45 lines (36 loc) · 1.2 KB
/
template_raw.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package controller
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/qb0C80aE/clay/extension"
"github.com/qb0C80aE/clay/logging"
"github.com/qb0C80aE/clay/model"
)
type templateRawController struct {
BaseController
}
func newTemplateRawController() *templateRawController {
return CreateController(&templateRawController{}, model.NewTemplateRaw()).(*templateRawController)
}
func (receiver *templateRawController) GetResourceSingleURL() (string, error) {
templateResourceName, err := extension.GetAssociatedResourceNameWithModel(model.NewTemplate())
if err != nil {
logging.Logger().Debug(err.Error())
return "", err
}
return fmt.Sprintf("%s/:key_parameter/raw", templateResourceName), nil
}
func (receiver *templateRawController) GetRouteMap() map[int]map[int]gin.HandlerFunc {
routeMap := map[int]map[int]gin.HandlerFunc{
extension.MethodGet: {
extension.URLSingle: receiver.GetSingle,
},
}
return routeMap
}
func (receiver *templateRawController) OutputGetSingle(c *gin.Context, code int, result interface{}, fields map[string]interface{}) {
receiver.BaseController.outputTextWithContentType(c, code, result)
}
func init() {
extension.RegisterController(newTemplateRawController())
}