Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rym-util
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengqiuyun
rym-util
Commits
4cd0b18a
Commit
4cd0b18a
authored
Oct 26, 2022
by
zhengqiuyun86
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go升级,泛型使用
parent
4b8063fb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
HttpUtil.go
util/HttpUtil.go
+13
-4
No files found.
util/HttpUtil.go
View file @
4cd0b18a
...
@@ -2,16 +2,25 @@ package util
...
@@ -2,16 +2,25 @@ package util
import
(
import
(
"bytes"
"bytes"
"fmt"
"git.168cad.top/zhengqiuyun/rym-util/exception"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"io"
"io"
"net/http"
"net/http"
"strings"
"strings"
)
)
func
Param
[
T
any
](
c
*
gin
.
Context
,
key
string
)
*
T
{
func
Param
[
T
any
](
c
*
gin
.
Context
,
key
string
)
T
{
if
val
,
ok
:=
c
.
Get
(
key
);
ok
&&
val
!=
nil
{
val
,
ok
:=
c
.
Get
(
key
)
i
,
_
:=
val
.
(
T
)
if
ok
{
return
&
i
exception
.
ThrowsErrS
(
"PARAMS_ERR"
,
fmt
.
Sprintf
(
"参数[%s]必传"
,
key
))
}
else
{
i
,
k
:=
val
.
(
T
)
if
k
{
return
i
}
else
{
exception
.
ThrowsErrS
(
"PARAMS_ERR"
,
fmt
.
Sprintf
(
"参数[%s]不合规"
,
key
))
}
}
}
return
nil
return
nil
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment