Ver Fonte

网关添加引出增删改查便捷接口

yjp há 1 ano atrás
pai
commit
25aa05454b

+ 9 - 9
convenient/entity_crud/service.go

@@ -253,7 +253,7 @@ func Query[O any](tableName string, callbacks *QueryCallbacks[O], conditionField
 	}
 }
 
-func GetByID[O any](tableName string, callbacks *QueryByIDCallbacks[O]) binding.ServiceFunc[O] {
+func GetByID[O any](tableName string, callbacks *GetByIDCallbacks[O]) binding.ServiceFunc[O] {
 	return func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (O, error) {
 		outputZero := reflectutils.Zero[O]()
 
@@ -271,12 +271,12 @@ func GetByID[O any](tableName string, callbacks *QueryByIDCallbacks[O]) binding.
 
 		err := e.CheckFieldID()
 		if err != nil {
-			return callbackOnQueryByIDErrorReturn(callbacks, e, err, i)
+			return callbackOnGetByIDErrorReturn(callbacks, e, err, i)
 		}
 
-		err = callbackBeforeQueryByID(callbacks, e, i)
+		err = callbackBeforeGetByID(callbacks, e, i)
 		if err != nil {
-			return callbackOnQueryByIDErrorReturn(callbacks, e, err, i)
+			return callbackOnGetByIDErrorReturn(callbacks, e, err, i)
 		}
 
 		result, err := database.QueryOne(dbExecutor, &sql.QueryOneExecuteParams{
@@ -288,21 +288,21 @@ func GetByID[O any](tableName string, callbacks *QueryByIDCallbacks[O]) binding.
 				err = fserr.New(e.DomainCNName() + "不存在")
 			}
 
-			return callbackOnQueryByIDErrorReturn(callbacks, e, err, i)
+			return callbackOnGetByIDErrorReturn(callbacks, e, err, i)
 		}
 
-		err = callbackAfterQueryByID(callbacks, e, i)
+		err = callbackAfterGetByID(callbacks, e, i)
 		if err != nil {
-			return callbackOnQueryByIDErrorReturn(callbacks, e, err, i)
+			return callbackOnGetByIDErrorReturn(callbacks, e, err, i)
 		}
 
 		info := reflectutils.Zero[O]()
 		err = sql.ParseSqlResult(result, &info)
 		if err != nil {
-			return callbackOnQueryByIDErrorReturn(callbacks, e, err, i)
+			return callbackOnGetByIDErrorReturn(callbacks, e, err, i)
 		}
 
-		return callbackOnQueryByIDSuccessReturn(callbacks, e, i, info)
+		return callbackOnGetByIDSuccessReturn(callbacks, e, i, info)
 	}
 }
 

+ 5 - 5
convenient/entity_crud/service_callbacks.go

@@ -271,14 +271,14 @@ func callbackOnQueryErrorReturn[O any](callbacks *QueryCallbacks[O], e entity.En
 	return callbacks.OnErrorReturn(e, err, i)
 }
 
-type QueryByIDCallbacks[O any] struct {
+type GetByIDCallbacks[O any] struct {
 	Before          func(e entity.Entity, i *infrastructure.Infrastructure) error
 	After           func(e entity.Entity, i *infrastructure.Infrastructure) error
 	OnSuccessReturn func(e entity.Entity, i *infrastructure.Infrastructure, output O) (O, error)
 	OnErrorReturn   func(e entity.Entity, err error, i *infrastructure.Infrastructure) (O, error)
 }
 
-func callbackBeforeQueryByID[O any](callbacks *QueryByIDCallbacks[O], e entity.Entity, i *infrastructure.Infrastructure) error {
+func callbackBeforeGetByID[O any](callbacks *GetByIDCallbacks[O], e entity.Entity, i *infrastructure.Infrastructure) error {
 	if callbacks == nil {
 		return nil
 	}
@@ -290,7 +290,7 @@ func callbackBeforeQueryByID[O any](callbacks *QueryByIDCallbacks[O], e entity.E
 	return callbacks.Before(e, i)
 }
 
-func callbackAfterQueryByID[O any](callbacks *QueryByIDCallbacks[O], e entity.Entity, i *infrastructure.Infrastructure) error {
+func callbackAfterGetByID[O any](callbacks *GetByIDCallbacks[O], e entity.Entity, i *infrastructure.Infrastructure) error {
 	if callbacks == nil {
 		return nil
 	}
@@ -302,7 +302,7 @@ func callbackAfterQueryByID[O any](callbacks *QueryByIDCallbacks[O], e entity.En
 	return callbacks.After(e, i)
 }
 
-func callbackOnQueryByIDSuccessReturn[O any](callbacks *QueryByIDCallbacks[O], e entity.Entity, i *infrastructure.Infrastructure, output O) (O, error) {
+func callbackOnGetByIDSuccessReturn[O any](callbacks *GetByIDCallbacks[O], e entity.Entity, i *infrastructure.Infrastructure, output O) (O, error) {
 	if callbacks == nil {
 		return output, nil
 	}
@@ -314,7 +314,7 @@ func callbackOnQueryByIDSuccessReturn[O any](callbacks *QueryByIDCallbacks[O], e
 	return callbacks.OnSuccessReturn(e, i, output)
 }
 
-func callbackOnQueryByIDErrorReturn[O any](callbacks *QueryByIDCallbacks[O], e entity.Entity, err error, i *infrastructure.Infrastructure) (O, error) {
+func callbackOnGetByIDErrorReturn[O any](callbacks *GetByIDCallbacks[O], e entity.Entity, err error, i *infrastructure.Infrastructure) (O, error) {
 	if callbacks == nil {
 		return reflectutils.Zero[O](), err
 	}

+ 24 - 24
convenient/entity_crud/simple.go

@@ -34,11 +34,11 @@ type Simple[I any] struct {
 	GetByIDQueryParams request.IDRequestParam
 
 	// 可选配置项,通过WithXXX配置
-	createOptions    *CreateOptions
-	deleteOptions    *DeleteOptions
-	updateOptions    *UpdateOptions
-	queryOptions     *QueryOptions[I]
-	queryByIDOptions *QueryByIDOptions[I]
+	createOptions  *CreateOptions
+	deleteOptions  *DeleteOptions
+	updateOptions  *UpdateOptions
+	queryOptions   *QueryOptions[I]
+	getByIDOptions *GetByIDOptions[I]
 }
 
 func (simple *Simple[I]) bind(binder *binding.Binder) {
@@ -46,7 +46,7 @@ func (simple *Simple[I]) bind(binder *binding.Binder) {
 	deleteOptions := simple.deleteOptions
 	updateOptions := simple.updateOptions
 	queryOptions := simple.queryOptions
-	queryByIDOptions := simple.queryByIDOptions
+	getByIDOptions := simple.getByIDOptions
 
 	tableName := domain.TableName(simple.Schema, simple.Entity)
 	domainPath := domain.RelativeDomainPath(simple.Entity)
@@ -126,14 +126,14 @@ func (simple *Simple[I]) bind(binder *binding.Binder) {
 	}
 
 	// 通过ID获取
-	if !queryByIDOptions.disableQueryByID {
+	if !getByIDOptions.disableGetByID {
 		binding.GetBind(binder, &binding.SimpleBindItem[I]{
 			Path:          domainPath + "/get",
 			ResponseFunc:  response.SendInfoResponse[I],
 			RequestParams: simple.GetByIDQueryParams,
 			Objects:       []domain.Object{simple.Entity},
-			ServiceFunc:   GetByID[I](tableName, queryByIDOptions.getByIDCallbacks),
-		}, queryByIDOptions.getByIDMiddlewares...)
+			ServiceFunc:   GetByID[I](tableName, getByIDOptions.getByIDCallbacks),
+		}, getByIDOptions.getByIDMiddlewares...)
 	}
 }
 
@@ -142,7 +142,7 @@ func BindSimple[I any](binder *binding.Binder, simple *Simple[I], opts ...any) {
 	deleteOptions := new(DeleteOptions)
 	updateOptions := new(UpdateOptions)
 	queryOptions := new(QueryOptions[I])
-	queryByIDOptions := new(QueryByIDOptions[I])
+	getByIDOptions := new(GetByIDOptions[I])
 
 	for _, opt := range opts {
 		switch o := opt.(type) {
@@ -154,8 +154,8 @@ func BindSimple[I any](binder *binding.Binder, simple *Simple[I], opts ...any) {
 			o(updateOptions)
 		case QueryOption[I]:
 			o(queryOptions)
-		case QueryByIDOption[I]:
-			o(queryByIDOptions)
+		case GetByIDOption[I]:
+			o(getByIDOptions)
 		default:
 			continue
 		}
@@ -165,7 +165,7 @@ func BindSimple[I any](binder *binding.Binder, simple *Simple[I], opts ...any) {
 	simple.deleteOptions = deleteOptions
 	simple.updateOptions = updateOptions
 	simple.queryOptions = queryOptions
-	simple.queryByIDOptions = queryByIDOptions
+	simple.getByIDOptions = getByIDOptions
 
 	simple.bind(binder)
 }
@@ -174,7 +174,7 @@ type CreateOption func(options *CreateOptions)
 type DeleteOption func(options *DeleteOptions)
 type UpdateOption func(options *UpdateOptions)
 type QueryOption[I any] func(options *QueryOptions[I])
-type QueryByIDOption[I any] func(options *QueryByIDOptions[I])
+type GetByIDOption[I any] func(options *GetByIDOptions[I])
 
 type CreateOptions struct {
 	// 关闭创建
@@ -232,12 +232,12 @@ type QueryOptions[I any] struct {
 	queryMiddlewares []api.Handler
 }
 
-type QueryByIDOptions[I any] struct {
+type GetByIDOptions[I any] struct {
 	// 关闭根据ID查询
-	disableQueryByID bool
+	disableGetByID bool
 
 	// 根据ID查询回调
-	getByIDCallbacks *QueryByIDCallbacks[I]
+	getByIDCallbacks *GetByIDCallbacks[I]
 
 	// 根据ID查询中间件
 	getByIDMiddlewares []api.Handler
@@ -339,20 +339,20 @@ func WithQueryMiddlewares[I any](middlewares []api.Handler) QueryOption[I] {
 	}
 }
 
-func WithDisableQueryByID[I any]() QueryByIDOption[I] {
-	return func(options *QueryByIDOptions[I]) {
-		options.disableQueryByID = true
+func WithDisableGetByID[I any]() GetByIDOption[I] {
+	return func(options *GetByIDOptions[I]) {
+		options.disableGetByID = true
 	}
 }
 
-func WithGetByIDCallbacks[I any](callbacks *QueryByIDCallbacks[I]) QueryByIDOption[I] {
-	return func(options *QueryByIDOptions[I]) {
+func WithGetByIDCallbacks[I any](callbacks *GetByIDCallbacks[I]) GetByIDOption[I] {
+	return func(options *GetByIDOptions[I]) {
 		options.getByIDCallbacks = callbacks
 	}
 }
 
-func WithGetByIDMiddlewares[I any](middlewares []api.Handler) QueryByIDOption[I] {
-	return func(options *QueryByIDOptions[I]) {
+func WithGetByIDMiddlewares[I any](middlewares []api.Handler) GetByIDOption[I] {
+	return func(options *GetByIDOptions[I]) {
 		options.getByIDMiddlewares = middlewares
 	}
 }

+ 268 - 0
convenient/gwtools/crud.go

@@ -0,0 +1,268 @@
+package gwtools
+
+import (
+	"git.sxidc.com/go-framework/baize/framework/core/api"
+	"git.sxidc.com/go-framework/baize/framework/gateway"
+	"git.sxidc.com/go-tools/utils/template"
+	"github.com/iancoleman/strcase"
+	"net/http"
+)
+
+func CRUD(builder *gateway.Builder, params *CommonCRUDParams, opts ...any) {
+	createOptions := new(CreateOptions)
+	deleteOptions := new(DeleteOptions)
+	updateOptions := new(UpdateOptions)
+	queryOptions := new(QueryOptions)
+	getByIDOptions := new(GetByIDOptions)
+
+	for _, opt := range opts {
+		switch o := opt.(type) {
+		case CreateOption:
+			o(createOptions)
+		case DeleteOption:
+			o(deleteOptions)
+		case UpdateOption:
+			o(updateOptions)
+		case QueryOption:
+			o(queryOptions)
+		case GetByIDOption:
+			o(getByIDOptions)
+		default:
+			continue
+		}
+	}
+
+	params.createOptions = createOptions
+	params.deleteOptions = deleteOptions
+	params.updateOptions = updateOptions
+	params.queryOptions = queryOptions
+	params.getByIDOptions = getByIDOptions
+
+	params.crud(builder)
+}
+
+type CommonCRUDParams struct {
+	// 除去后缀的服务URL,如http://localhost:8080/example/api/v1
+	ServiceVersionedUrl string
+
+	// 领域名称
+	DomainCamelName string
+
+	CreateMiddlewares  []api.Handler
+	DeleteMiddlewares  []api.Handler
+	UpdateMiddlewares  []api.Handler
+	QueryMiddlewares   []api.Handler
+	GetByIDMiddlewares []api.Handler
+
+	// 可选配置项,通过WithXXX配置
+	createOptions  *CreateOptions
+	deleteOptions  *DeleteOptions
+	updateOptions  *UpdateOptions
+	queryOptions   *QueryOptions
+	getByIDOptions *GetByIDOptions
+}
+
+func (params *CommonCRUDParams) crud(builder *gateway.Builder) {
+	createOptions := params.createOptions
+	deleteOptions := params.deleteOptions
+	updateOptions := params.updateOptions
+	queryOptions := params.queryOptions
+	getByIDOptions := params.getByIDOptions
+
+	domainPath := "/" + strcase.ToLowerCamel(template.Id(params.DomainCamelName))
+
+	// 创建
+	if !createOptions.disableCreate {
+		builder.
+			Url(http.MethodPost, domainPath+"/create").
+			Post(&gateway.PostRequest{
+				Url: params.ServiceVersionedUrl + domainPath + "/create",
+			}, createOptions.createCallback).
+			Build(createOptions.createMiddlewares...)
+	}
+
+	// 删除
+	if !deleteOptions.disableDelete {
+		builder.
+			Url(http.MethodDelete, domainPath+"/delete").
+			Delete(&gateway.DeleteRequest{
+				Url: params.ServiceVersionedUrl + domainPath + "/delete",
+			}, deleteOptions.deleteCallback).
+			Build(deleteOptions.deleteMiddlewares...)
+	}
+
+	// 修改
+	if !updateOptions.disableUpdate {
+		builder.
+			Url(http.MethodPut, domainPath+"/update").
+			Put(&gateway.PutRequest{
+				Url: params.ServiceVersionedUrl + domainPath + "/update",
+			}, updateOptions.updateCallback).
+			Build(updateOptions.updateMiddlewares...)
+	}
+
+	// 查询
+	if !queryOptions.disableQuery {
+		builder.
+			Url(http.MethodGet, domainPath+"/query").
+			Get(&gateway.GetRequest{
+				Url: params.ServiceVersionedUrl + domainPath + "/query",
+			}, queryOptions.queryCallback).
+			Build(queryOptions.queryMiddlewares...)
+	}
+
+	// 通过ID获取
+	if !getByIDOptions.disableGetByID {
+		builder.
+			Url(http.MethodGet, domainPath+"/get").
+			Get(&gateway.GetRequest{
+				Url: params.ServiceVersionedUrl + domainPath + "/get",
+			}, getByIDOptions.getByIDCallback).
+			Build(getByIDOptions.getByIDMiddlewares...)
+	}
+}
+
+type CreateOption func(options *CreateOptions)
+type DeleteOption func(options *DeleteOptions)
+type UpdateOption func(options *UpdateOptions)
+type QueryOption func(options *QueryOptions)
+type GetByIDOption func(options *GetByIDOptions)
+
+type CreateOptions struct {
+	// 关闭创建
+	disableCreate bool
+
+	// 创建回调
+	createCallback gateway.RequestCallbackFunc
+
+	// 创建中间件
+	createMiddlewares []api.Handler
+}
+
+type DeleteOptions struct {
+	// 关闭删除
+	disableDelete bool
+
+	// 删除回调
+	deleteCallback gateway.RequestCallbackFunc
+
+	// 删除中间件
+	deleteMiddlewares []api.Handler
+}
+
+type UpdateOptions struct {
+	// 关闭更新
+	disableUpdate bool
+
+	// 更新回调
+	updateCallback gateway.RequestCallbackFunc
+
+	// 更新中间件
+	updateMiddlewares []api.Handler
+}
+
+type QueryOptions struct {
+	// 关闭查询
+	disableQuery bool
+
+	// 查询回调
+	queryCallback gateway.RequestCallbackFunc
+
+	// 查询中间件
+	queryMiddlewares []api.Handler
+}
+
+type GetByIDOptions struct {
+	// 关闭根据ID查询
+	disableGetByID bool
+
+	// 根据ID查询回调
+	getByIDCallback gateway.RequestCallbackFunc
+
+	// 根据ID查询中间件
+	getByIDMiddlewares []api.Handler
+}
+
+func WithCreateCallbacks(callbacks gateway.RequestCallbackFunc) CreateOption {
+	return func(options *CreateOptions) {
+		options.createCallback = callbacks
+	}
+}
+
+func WithCreateMiddlewares(middlewares []api.Handler) CreateOption {
+	return func(options *CreateOptions) {
+		options.createMiddlewares = middlewares
+	}
+}
+
+func WithDisableDelete() DeleteOption {
+	return func(options *DeleteOptions) {
+		options.disableDelete = true
+	}
+}
+
+func WithDeleteCallbacks(callbacks gateway.RequestCallbackFunc) DeleteOption {
+	return func(options *DeleteOptions) {
+		options.deleteCallback = callbacks
+	}
+}
+
+func WithDeleteMiddlewares(middlewares []api.Handler) DeleteOption {
+	return func(options *DeleteOptions) {
+		options.deleteMiddlewares = middlewares
+	}
+}
+
+func WithDisableUpdate() UpdateOption {
+	return func(options *UpdateOptions) {
+		options.disableUpdate = true
+	}
+}
+
+func WithUpdateCallbacks(callbacks gateway.RequestCallbackFunc) UpdateOption {
+	return func(options *UpdateOptions) {
+		options.updateCallback = callbacks
+	}
+}
+
+func WithUpdateMiddlewares(middlewares []api.Handler) UpdateOption {
+	return func(options *UpdateOptions) {
+		options.updateMiddlewares = middlewares
+	}
+}
+
+func WithDisableQuery() QueryOption {
+	return func(options *QueryOptions) {
+		options.disableQuery = true
+	}
+}
+
+func WithQueryCallbacks(callbacks gateway.RequestCallbackFunc) QueryOption {
+	return func(options *QueryOptions) {
+		options.queryCallback = callbacks
+	}
+}
+
+func WithQueryMiddlewares(middlewares []api.Handler) QueryOption {
+	return func(options *QueryOptions) {
+		options.queryMiddlewares = middlewares
+	}
+}
+
+func WithDisableGetByID() GetByIDOption {
+	return func(options *GetByIDOptions) {
+		options.disableGetByID = true
+	}
+}
+
+func WithGetByIDCallbacks(callbacks gateway.RequestCallbackFunc) GetByIDOption {
+	return func(options *GetByIDOptions) {
+		options.getByIDCallback = callbacks
+	}
+}
+
+func WithGetByIDMiddlewares(middlewares []api.Handler) GetByIDOption {
+	return func(options *GetByIDOptions) {
+		options.getByIDMiddlewares = middlewares
+	}
+}

+ 45 - 0
framework/core/api/context.go

@@ -1,10 +1,12 @@
 package api
 
 import (
+	"bytes"
 	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/logger"
 	"github.com/gin-gonic/gin"
 	"io"
 	"mime/multipart"
+	"strings"
 )
 
 type Context struct {
@@ -33,3 +35,46 @@ func (c *Context) GetFileHeaderBytes(fileHeader *multipart.FileHeader) (string,
 
 	return fileHeader.Filename, contentBytes, nil
 }
+
+func (c *Context) ReadBody() ([]byte, error) {
+	if c.Request.Body == nil {
+		return make([]byte, 0), nil
+	}
+
+	body, err := io.ReadAll(c.Request.Body)
+	if err != nil {
+		return nil, err
+	}
+
+	defer func(Body io.ReadCloser) {
+		err := Body.Close()
+		if err != nil {
+			logger.GetInstance().Error(err)
+			return
+		}
+	}(c.Request.Body)
+
+	c.Request.Body = io.NopCloser(bytes.NewBuffer(body))
+
+	return body, nil
+}
+
+func (c *Context) GetAllQueryParams() map[string]string {
+	queryParams := make(map[string]string, 0)
+
+	for key, value := range c.Request.URL.Query() {
+		queryParams[key] = strings.Join(value, ",")
+	}
+
+	return queryParams
+}
+
+func (c *Context) GetAllPathParams() map[string]string {
+	pathParams := make(map[string]string, 0)
+
+	for _, params := range c.Params {
+		pathParams[params.Key] = params.Value
+	}
+
+	return pathParams
+}

+ 5 - 1
framework/gateway/builder.go

@@ -39,6 +39,10 @@ func (builder *Builder) Post(request *PostRequest, requestCallbackFunc RequestCa
 	return builder.addRequest(newBuilderRequestItem(request, requestCallbackFunc))
 }
 
+func (builder *Builder) PostStruct(request *PostRequest, requestCallbackFunc RequestCallbackFunc) *Builder {
+	return builder.addRequest(newBuilderRequestItem(request, requestCallbackFunc))
+}
+
 func (builder *Builder) Delete(request *DeleteRequest, requestCallbackFunc RequestCallbackFunc) *Builder {
 	return builder.addRequest(newBuilderRequestItem(request, requestCallbackFunc))
 }
@@ -78,7 +82,7 @@ func (builder *Builder) Build(middlewares ...api.Handler) {
 			resultMap := make(map[string]any)
 
 			for _, requestItem := range builder.params.requestItems {
-				err := requestItem.request.Request(httpRequest)
+				err := requestItem.request.Request(c, httpRequest)
 				if err != nil {
 					builder.params.responseErrorFunc(c, err)
 					return

+ 41 - 6
framework/gateway/builder_request.go

@@ -1,6 +1,7 @@
 package gateway
 
 import (
+	"git.sxidc.com/go-framework/baize/framework/core/api"
 	"git.sxidc.com/go-tools/utils/http_client"
 	"net/http"
 )
@@ -8,14 +9,14 @@ import (
 type BuilderRequest interface {
 	HttpMethod() string
 	RequestUrl() string
-	Request(request *http_client.Request) error
+	Request(c *api.Context, request *http_client.Request) error
 	Response() *http_client.Response
 }
 
 type PostRequest struct {
 	Url     string
 	Headers map[string]string
-	Body    []byte
+	Body    any
 
 	response *http_client.Response
 }
@@ -28,7 +29,16 @@ func (req *PostRequest) RequestUrl() string {
 	return req.Url
 }
 
-func (req *PostRequest) Request(request *http_client.Request) error {
+func (req *PostRequest) Request(c *api.Context, request *http_client.Request) error {
+	if req.Body == nil {
+		body, err := c.ReadBody()
+		if err != nil {
+			return err
+		}
+
+		req.Body = body
+	}
+
 	response, err := request.Post(req.Url, req.Body,
 		http_client.WithRequestHeaders(req.Headers))
 	if err != nil {
@@ -61,7 +71,15 @@ func (req *DeleteRequest) RequestUrl() string {
 	return req.Url
 }
 
-func (req *DeleteRequest) Request(request *http_client.Request) error {
+func (req *DeleteRequest) Request(c *api.Context, request *http_client.Request) error {
+	if req.QueryParams == nil || len(req.QueryParams) == 0 {
+		req.QueryParams = c.GetAllQueryParams()
+	}
+
+	if req.PathParams == nil || len(req.PathParams) == 0 {
+		req.PathParams = c.GetAllPathParams()
+	}
+
 	response, err := request.Delete(req.Url,
 		http_client.WithRequestHeaders(req.Headers),
 		http_client.WithRequestPathParams(req.PathParams),
@@ -95,7 +113,16 @@ func (req *PutRequest) RequestUrl() string {
 	return req.Url
 }
 
-func (req *PutRequest) Request(request *http_client.Request) error {
+func (req *PutRequest) Request(c *api.Context, request *http_client.Request) error {
+	if req.Body == nil {
+		body, err := c.ReadBody()
+		if err != nil {
+			return err
+		}
+
+		req.Body = body
+	}
+
 	response, err := request.Put(req.Url, req.Body,
 		http_client.WithRequestHeaders(req.Headers))
 	if err != nil {
@@ -128,7 +155,15 @@ func (req *GetRequest) RequestUrl() string {
 	return req.Url
 }
 
-func (req *GetRequest) Request(request *http_client.Request) error {
+func (req *GetRequest) Request(c *api.Context, request *http_client.Request) error {
+	if req.QueryParams == nil || len(req.QueryParams) == 0 {
+		req.QueryParams = c.GetAllQueryParams()
+	}
+
+	if req.PathParams == nil || len(req.PathParams) == 0 {
+		req.PathParams = c.GetAllPathParams()
+	}
+
 	response, err := request.Get(req.Url,
 		http_client.WithRequestHeaders(req.Headers),
 		http_client.WithRequestPathParams(req.PathParams),