Chore: format code

This commit is contained in:
loyalsoldier
2021-05-18 23:16:04 +08:00
parent 8f9eccefe9
commit 2b7401109f
33 changed files with 51 additions and 76 deletions

View File

@@ -436,6 +436,7 @@ func (c *Controller) URLFor(endpoint string, values ...interface{}) string {
}
return URLFor(endpoint, values...)
}
// Resp sends response based on the Accept Header
// By default response will be in JSON
func (c *Controller) Resp(data interface{}) error {

View File

@@ -152,7 +152,6 @@ func (l *limiter) createBucket(key string) bucket {
return b
}
func defaultSessionKey(r *http.Request) string {
return ""
}

View File

@@ -94,4 +94,4 @@ func registerGzip() error {
)
}
return nil
}
}

View File

@@ -24,4 +24,4 @@ func NewMockContext(req *http.Request) (*beegoCtx.Context, *HttpResponse) {
resp := NewMockHttpResponse()
ctx.Reset(resp, req)
return ctx, resp
}
}

View File

@@ -58,7 +58,7 @@ func (c *TestController) HelloSession() {
c.Ctx.WriteString("set")
}
func (c *TestController) HelloSessionName() {
func (c *TestController) HelloSessionName() {
name := c.CruSession.Get(context.Background(), "name")
c.Ctx.WriteString(name.(string))
}
}

View File

@@ -29,7 +29,7 @@ type HttpResponse struct {
// NewMockHttpResponse you should only use this in your test code
func NewMockHttpResponse() *HttpResponse {
return &HttpResponse{
body: make([]byte, 0),
body: make([]byte, 0),
header: make(http.Header),
}
}

View File

@@ -66,7 +66,7 @@ func (s *SessionProvider) SessionRegenerate(ctx context.Context, oldsid, sid str
// SessionDestroy reset Store to nil
func (s *SessionProvider) SessionDestroy(ctx context.Context, sid string) error {
s.Store = nil;
s.Store = nil
return nil
}
@@ -80,14 +80,13 @@ func (s *SessionProvider) SessionGC(ctx context.Context) {
// we do anything since we don't need to mock GC
}
type SessionStore struct {
sid string
sid string
values map[interface{}]interface{}
}
func (s *SessionStore) Set(ctx context.Context, key, value interface{}) error {
s.values[key]=value
s.values[key] = value
return nil
}
@@ -116,10 +115,7 @@ func (s *SessionStore) Flush(ctx context.Context) error {
func newSessionStore() *SessionStore {
return &SessionStore{
sid: uuid.New().String(),
sid: uuid.New().String(),
values: make(map[interface{}]interface{}, 4),
}
}

View File

@@ -45,4 +45,3 @@ func TestSessionProvider(t *testing.T) {
assert.Equal(t, "Tom", result)
}

View File

@@ -738,7 +738,7 @@ func (p *ControllerRegister) AddAutoPrefix(prefix string, c ControllerInterface)
}
}
func (p *ControllerRegister) addAutoPrefixMethod(prefix, controllerName, methodName string, ctrl reflect.Type) {
func (p *ControllerRegister) addAutoPrefixMethod(prefix, controllerName, methodName string, ctrl reflect.Type) {
pattern := path.Join(prefix, strings.ToLower(controllerName), strings.ToLower(methodName), "*")
patternInit := path.Join(prefix, controllerName, methodName, "*")
patternFix := path.Join(prefix, strings.ToLower(controllerName), strings.ToLower(methodName))