Skip to content

Commit 86eb84a

Browse files
authored
[type: refactor] refactor envcd context build. (#86)
1 parent 2607630 commit 86eb84a

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

internal/core/openapi/auth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ package openapi
1919

2020
import (
2121
"fmt"
22+
2223
"github.com/acmestack/envcd/internal/core/plugin"
2324
"github.com/acmestack/envcd/internal/core/storage/dao"
2425
"github.com/acmestack/envcd/internal/pkg/context"
2526
"github.com/acmestack/envcd/internal/pkg/entity"
26-
"github.com/acmestack/envcd/internal/util"
2727
"github.com/acmestack/envcd/pkg/entity/data"
2828
"github.com/acmestack/godkits/gox/errorsx"
2929
"github.com/acmestack/godkits/gox/stringsx"
@@ -42,7 +42,7 @@ func (openapi *Openapi) login(ctx *gin.Context) {
4242
}
4343

4444
func (openapi *Openapi) logout(ctx *gin.Context) {
45-
c, _ := util.BuildContext(ctx)
45+
c, _ := buildContext(ctx)
4646
c.Action = func() (*data.EnvcdResult, error) {
4747
fmt.Println("hello world")
4848
// UserDao.save(),

internal/util/contextutil.go renamed to internal/core/openapi/context.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
1-
package util
1+
/*
2+
* Copyright (c) 2022, AcmeStack
3+
* All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package openapi
219

320
import (
21+
"io/ioutil"
22+
423
"github.com/acmestack/envcd/internal/pkg/context"
524
"github.com/acmestack/envcd/pkg/entity/data"
625
"github.com/gin-gonic/gin"
7-
"io/ioutil"
826
)
927

10-
// BuildContext build plugin context
28+
// buildContext build plugin context
1129
// @param params params
1230
// @return *context.Context context
1331
// @return error error
14-
func BuildContext(ginCtx *gin.Context) (*context.Context, error) {
32+
func buildContext(ginCtx *gin.Context) (*context.Context, error) {
1533
ctx := &context.Context{
1634
Uri: ginCtx.Request.RequestURI,
1735
Method: ginCtx.Request.Method,
@@ -27,11 +45,11 @@ func BuildContext(ginCtx *gin.Context) (*context.Context, error) {
2745
return nil, nil
2846
}
2947

30-
// ParseContext parse context to envcd data
48+
// parseContext parse context to envcd data
3149
// @param ctx context
3250
// @return *data.EnvcdData data
3351
// @return error error
34-
func ParseContext(ctx *context.Context) (*data.EnvcdData, error) {
52+
func parseContext(ctx *context.Context) (*data.EnvcdData, error) {
3553
// TODO parse context to envcd data
3654
return nil, nil
3755
}

0 commit comments

Comments
 (0)