From 45a17535e9f8a43e215579987b05c27ce46948b6 Mon Sep 17 00:00:00 2001 From: Notealot <714804968@qq.com> Date: Thu, 21 Oct 2021 10:34:53 +0800 Subject: [PATCH] refactor switch to if statement --- context.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/context.go b/context.go index d12771e48a..5172fba6a3 100644 --- a/context.go +++ b/context.go @@ -740,10 +740,7 @@ func (c *Context) ShouldBindBodyWith(obj interface{}, bb binding.BindingBody) (e // the remote IP (coming form Request.RemoteAddr) is returned. func (c *Context) ClientIP() string { // Check if we're running on a trusted platform, continue running backwards if error - switch c.engine.TrustedPlatform { - case "": - // TrustedPlatform is empty, do nothing - default: + if c.engine.TrustedPlatform != "" { // Developers can define their own header of Trusted Platform or use predefined constants if addr := c.requestHeader(c.engine.TrustedPlatform); addr != "" { return addr