| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- package main
- import (
- "fmt"
- "net/http"
- "github.com/gin-gonic/gin"
- )
- type queryHeader struct {
- MyHeader string `header:"my_header"`
- MyDemo string `header:"my_demo"`
- XChain string `header:"X-Chain"`
- Key string `header:"x-api-key"`
- }
- type queryBody struct {
- Name string `json:"name"`
- Age int `json:"age"`
- Sex int `json:"sex"`
- }
- type Req struct {
- Data []ClassReq `json:"data"`
- }
- type ClassReq struct {
- SeriesName string `json:"seriesName"`
- SeriesIssuer string `json:"seriesIssuer"`
- ExternalUrl string `json:"externalUrl"`
- SeriesDes string `json:"seriesDes"`
- SeriesId []string `json:"seriesId"`
- TotalDNA int64 `json:"totalDNA"`
- AssetContracts string `json:"asset_contracts"`
- }
- type queryParameter struct {
- // Year int `form:"year"`
- // Month int `form:"month"`
- Code string `form:"code"`
- }
- type queryUri struct {
- Id int `uri:"id"`
- Name string `uri:"name"`
- }
- func bindUri(context *gin.Context) {
- var q queryUri
- err := context.ShouldBindUri(&q)
- if err != nil {
- context.JSON(http.StatusBadRequest, gin.H{
- "result": err.Error(),
- })
- return
- }
- context.JSON(http.StatusOK, gin.H{
- "result": "绑定成功",
- "uri": q,
- })
- }
- func bindQuery(context *gin.Context) {
- var q queryParameter
- err := context.ShouldBindQuery(&q)
- if err != nil {
- context.JSON(http.StatusBadRequest, gin.H{
- "result": err.Error(),
- })
- return
- }
- context.JSON(http.StatusOK, gin.H{
- "result": "绑定成功",
- "query": q,
- })
- }
- func bindBody(context *gin.Context) {
- fmt.Println(context.Request.Body)
- var q Req
- err := context.ShouldBindJSON(&q)
- if err != nil {
- fmt.Println(err.Error())
- context.JSON(http.StatusBadRequest, gin.H{
- "result": err.Error(),
- })
- return
- }
- fmt.Printf("%v\n", q)
- context.JSON(http.StatusOK, gin.H{
- "result": "绑定成功",
- "body": q,
- })
- }
- func bindhead(context *gin.Context) {
- var q queryHeader
- err := context.ShouldBindHeader(&q)
- if err != nil {
- context.JSON(http.StatusBadRequest, gin.H{
- "result": err.Error(),
- })
- return
- }
- context.JSON(http.StatusUnauthorized, gin.H{
- "result": "绑定成功",
- "header": q,
- })
- }
- func main() {
- srv := gin.Default()
- srv.GET("/binding/header", bindhead)
- srv.POST("/binding/body", bindBody)
- srv.GET("/binding/query", bindQuery)
- srv.GET("/binding/:id/:name", bindUri)
- // srv.Use(CORSMiddleware())
- srv.Run(":9999")
- }
- func CORSMiddleware() gin.HandlerFunc {
- // 配置跨域
- return func(c *gin.Context) {
- // 允许的请求源,这里设置为允许所有来源
- c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
- // 允许的请求方法
- c.Writer.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
- // 允许的请求头
- // c.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type,Accept-Language,X-Requested-With,Global")
- c.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type,Accept-Language,X-Requested-With,Global,Accept,Accept-Encoding,Accept-Language,Cache-Control,Connection,Host,Origin,Pragma,Referer,User-Agent,X-Chain")
- // 处理 OPTIONS 请求
- if c.Request.Method == http.MethodOptions {
- // 返回成功状态码
- c.AbortWithStatus(http.StatusOK)
- return
- }
- c.Next()
- }
- }
- var html = `<!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
- <meta
- name="keywords"
- content="Avata api,AVATA API,Avata 平台,Avata v3 API,Avata console 平台,Avata 服务,AVATA 平台,AVATA 服务平台,AVATA API 平台,Avata 控制台,边界智能Avata,文昌链接口平台,文昌链API,多链API服务平台,跨链API服务平台,区块链API服务"
- />
- <meta
- name="description"
- content="AVATA 是由边界智能基于区块链底层核心技术以及支持复杂分布式 商业应用的经验,自主研发的多链 / 跨链 NFT/ 元宇宙应用 API 服务平台。"
- />
- <meta
- property="og:description"
- content="「Avata」由边界智能自主研发、将区块链底层复杂交互逻辑封装成的一款多链/跨链 NFT/元宇宙应用 API 服务平台型产品。助力开发者和企业打造开放、多元的分布式商业形态。"
- />
- <meta property="og:title" content="Avata 服务平台-边界智能" />
- <meta
- property="og:image"
- content="https://www.bianjie.ai/resources/Avata/Avata_share.png"
- />
- <meta
- name="viewport"
- content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
- />
- <title>Avata 服务平台</title>
- <link rel="icon" href="/logo.png" type="image/x-icon" />
- <link rel="stylesheet" href="/umi.0cebcf47.css" />
- <script>
- window.routerBase = "/";
- </script>
- <script>
- //! umi version: 3.5.21
- </script>
- </head>
- <!-- <script>
- var _hmt = _hmt || [];
- (function () {
- var hm = document.createElement('script');
- hm.src = 'https://hm.baidu.com/hm.js?ae855a2ddad87d95ed80d0de0b180679';
- var s = document.getElementsByTagName('script')[0];
- s.parentNode.insertBefore(hm, s);
- })();
- </script> -->
- <body>
- <noscript>
- <div class="noscript-container">
- Hi there! Please
- <div class="noscript-enableJS">
- <a
- href="https://www.enablejavascript.io/en"
- target="_blank"
- rel="noopener noreferrer"
- >
- <b>enable Javascript</b>
- </a>
- </div>
- in your browser to use Ant Design, Out-of-the-box mid-stage front/design
- solution!
- </div>
- </noscript>
- <div id="root">
- <style>
- html,
- body,
- #root {
- height: 100%;
- margin: 0;
- padding: 0;
- }
- #root {
- background-repeat: no-repeat;
- background-size: 100% auto;
- }
- .noscript-container {
- display: flex;
- align-content: center;
- justify-content: center;
- margin-top: 90px;
- font-size: 20px;
- font-family: "Lucida Sans", "Lucida Sans Regular", "Lucida Grande",
- "Lucida Sans Unicode", Geneva, Verdana, sans-serif;
- }
- .noscript-enableJS {
- padding-right: 3px;
- padding-left: 3px;
- }
- .page-loading-warp {
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 98px;
- }
- .ant-spin {
- position: absolute;
- display: none;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- color: rgba(0, 0, 0, 0.65);
- color: #1890ff;
- font-size: 14px;
- font-variant: tabular-nums;
- line-height: 1.5;
- text-align: center;
- list-style: none;
- opacity: 0;
- -webkit-transition: -webkit-transform 0.3s
- cubic-bezier(0.78, 0.14, 0.15, 0.86);
- transition: -webkit-transform 0.3s
- cubic-bezier(0.78, 0.14, 0.15, 0.86);
- transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
- transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86),
- -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
- -webkit-font-feature-settings: "tnum";
- font-feature-settings: "tnum";
- }
- .ant-spin-spinning {
- position: static;
- display: inline-block;
- opacity: 1;
- }
- .ant-spin-dot {
- position: relative;
- display: inline-block;
- width: 20px;
- height: 20px;
- font-size: 20px;
- }
- .ant-spin-dot-item {
- position: absolute;
- display: block;
- width: 9px;
- height: 9px;
- background-color: #1890ff;
- border-radius: 100%;
- -webkit-transform: scale(0.75);
- -ms-transform: scale(0.75);
- transform: scale(0.75);
- -webkit-transform-origin: 50% 50%;
- -ms-transform-origin: 50% 50%;
- transform-origin: 50% 50%;
- opacity: 0.3;
- -webkit-animation: antspinmove 1s infinite linear alternate;
- animation: antSpinMove 1s infinite linear alternate;
- }
- .ant-spin-dot-item:nth-child(1) {
- top: 0;
- left: 0;
- }
- .ant-spin-dot-item:nth-child(2) {
- top: 0;
- right: 0;
- -webkit-animation-delay: 0.4s;
- animation-delay: 0.4s;
- }
- .ant-spin-dot-item:nth-child(3) {
- right: 0;
- bottom: 0;
- -webkit-animation-delay: 0.8s;
- animation-delay: 0.8s;
- }
- .ant-spin-dot-item:nth-child(4) {
- bottom: 0;
- left: 0;
- -webkit-animation-delay: 1.2s;
- animation-delay: 1.2s;
- }
- .ant-spin-dot-spin {
- -webkit-transform: rotate(45deg);
- -ms-transform: rotate(45deg);
- transform: rotate(45deg);
- -webkit-animation: antrotate 1.2s infinite linear;
- animation: antRotate 1.2s infinite linear;
- }
- .ant-spin-lg .ant-spin-dot {
- width: 32px;
- height: 32px;
- font-size: 32px;
- }
- .ant-spin-lg .ant-spin-dot i {
- width: 14px;
- height: 14px;
- }
- @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
- .ant-spin-blur {
- background: #fff;
- opacity: 0.5;
- }
- }
- @-webkit-keyframes antSpinMove {
- to {
- opacity: 1;
- }
- }
- @keyframes antSpinMove {
- to {
- opacity: 1;
- }
- }
- @-webkit-keyframes antRotate {
- to {
- -webkit-transform: rotate(405deg);
- transform: rotate(405deg);
- }
- }
- @keyframes antRotate {
- to {
- -webkit-transform: rotate(405deg);
- transform: rotate(405deg);
- }
- }
- </style>
- <!-- <div
- style="
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- height: 100%;
- min-height: 420px;
- "
- >
- <img
- src="/pro_icon.svg"
- alt="logo"
- width="256"
- />
- <div class="page-loading-warp">
- <div class="ant-spin ant-spin-lg ant-spin-spinning">
- <span class="ant-spin-dot ant-spin-dot-spin"
- ><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i
- ><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i
- ></span>
- </div>
- </div>
- <div
- style="display: flex; align-items: center; justify-content: center"
- >
- <img
- src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
- width="32"
- style="margin-right: 8px"
- />
- Ant Design
- </div>
- </div> -->
- </div>
- <script src="/umi.12fd7d0e.js"></script>
- </body>
- </html>`
|