-
Notifications
You must be signed in to change notification settings - Fork 2
/
trees_server.gen.go
157 lines (127 loc) · 5.33 KB
/
trees_server.gen.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// Package trees provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen version v1.11.0 DO NOT EDIT.
package trees
import (
"fmt"
"net/http"
"github.com/deepmap/oapi-codegen/pkg/runtime"
"github.com/labstack/echo/v4"
)
// ServerInterface represents all server handlers.
type ServerInterface interface {
// List returns a list of trees
// (GET /trees)
List(ctx echo.Context, params ListParams) error
// Create will create a new tree
// (POST /trees)
Create(ctx echo.Context) error
// Delete allows to delete a specific treeId
// (DELETE /trees/{treeId})
Delete(ctx echo.Context, treeId int32) error
// Get will retrieve in backend all information about a specific treeId
// (GET /trees/{treeId})
Get(ctx echo.Context, treeId int32) error
// Update allows to modify information about a specific treeId
// (PUT /trees/{treeId})
Update(ctx echo.Context, treeId int32) error
}
// ServerInterfaceWrapper converts echo contexts to parameters.
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
// List converts echo context to params.
func (w *ServerInterfaceWrapper) List(ctx echo.Context) error {
var err error
ctx.Set(JWTAuthScopes, []string{""})
// Parameter object where we will unmarshal all parameters from the context
var params ListParams
// ------------- Optional query parameter "limit" -------------
err = runtime.BindQueryParameter("form", true, false, "limit", ctx.QueryParams(), ¶ms.Limit)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter limit: %s", err))
}
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.List(ctx, params)
return err
}
// Create converts echo context to params.
func (w *ServerInterfaceWrapper) Create(ctx echo.Context) error {
var err error
ctx.Set(JWTAuthScopes, []string{""})
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.Create(ctx)
return err
}
// Delete converts echo context to params.
func (w *ServerInterfaceWrapper) Delete(ctx echo.Context) error {
var err error
// ------------- Path parameter "treeId" -------------
var treeId int32
err = runtime.BindStyledParameterWithLocation("simple", false, "treeId", runtime.ParamLocationPath, ctx.Param("treeId"), &treeId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter treeId: %s", err))
}
ctx.Set(JWTAuthScopes, []string{""})
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.Delete(ctx, treeId)
return err
}
// Get converts echo context to params.
func (w *ServerInterfaceWrapper) Get(ctx echo.Context) error {
var err error
// ------------- Path parameter "treeId" -------------
var treeId int32
err = runtime.BindStyledParameterWithLocation("simple", false, "treeId", runtime.ParamLocationPath, ctx.Param("treeId"), &treeId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter treeId: %s", err))
}
ctx.Set(JWTAuthScopes, []string{""})
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.Get(ctx, treeId)
return err
}
// Update converts echo context to params.
func (w *ServerInterfaceWrapper) Update(ctx echo.Context) error {
var err error
// ------------- Path parameter "treeId" -------------
var treeId int32
err = runtime.BindStyledParameterWithLocation("simple", false, "treeId", runtime.ParamLocationPath, ctx.Param("treeId"), &treeId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter treeId: %s", err))
}
ctx.Set(JWTAuthScopes, []string{""})
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.Update(ctx, treeId)
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+"/trees", wrapper.List)
router.POST(baseURL+"/trees", wrapper.Create)
router.DELETE(baseURL+"/trees/:treeId", wrapper.Delete)
router.GET(baseURL+"/trees/:treeId", wrapper.Get)
router.PUT(baseURL+"/trees/:treeId", wrapper.Update)
}