// Copyright (c) 2021. Huawei Technologies Co., Ltd. All rights reserved.

// Package common define common utils
package common

import (
"errors"
"net/http"
"strconv"
)

// ConvertToUint64 convert string to uint64
func ConvertToUint64(ID string) (uint64, error) {
id, err := strconv.ParseUint(ID, BaseHex, BitSize64)
return id, err
}

// GetHTTPHandler new HTTPHandler with http client
// 1. client with http;
// 2. client with https one way auth;
// 3. client with https two way auth;
func GetHTTPHandler(enableHTTP bool, authMode string) (*HTTPHandler, error) {
// http auth
if enableHTTP {
return &HTTPHandler{
Client: new(http.Client),
}, nil
}

wc := GetWebCertUtil()
if wc == nil {
return nil, errors.New("cannot get https one/two way auth handler because cert util is nil")
}
client, err := wc.GetRequestClient(authMode)
if err != nil {
return nil, err
}

return &HTTPHandler{
Client: client,
}, nil
}

mindxdl--common--utils.go的更多相关文章

  1. Java-Class-Miniprogram:com.common.utils.miniprogram.Auth

    ylbtech-Java-Class-miniprogram:com.common.utils.miniprogram.Auth 1.返回顶部 1.1. package com.ylbtech.com ...

  2. Java-Class-Miniprogram:com.ylbtech.common.utils.miniprogram.TemplateMessage

    ylbtech-Java-Class-Miniprogram:com.ylbtech.common.utils.miniprogram.TemplateMessage 1.返回顶部 1.1. pack ...

  3. 全网最详细的启动Kafka服务时出现kafka.common.InconsistentBrokerIdException: Configured brokerId 3 doesn't match stored brokerId 1 in meta.properties错误的解决办法(图文详解)

    不多说,直接上干货! 问题详情 执行bin/kafka-server-start.sh config/server.properties 时, [kfk@bigdata-pro03 kafka_2.- ...

  4. Java各种Utils小结

    原文地址:http://trinea.iteye.com/blog/1533616 最新内容建议直接访问原文:Android常用的工具类 主要介绍总结的Android开发中常用的工具类,大部分同样适用 ...

  5. Java Base64Utils ----Utils

    Java Base64Utils   目录   Java Base64Utils 7 /**  * <html>  * <body>  *  <P> Copyrig ...

  6. 缓存工具类CacheHelper

    代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Syst ...

  7. MVC还是MVVM?或许VMVC更适合WinForm客户端

    最近开始重构一个稍嫌古老的C/S项目,原先采用的技术栈是『WinForm』+『WCF』+『EF』.相对于现在铺天盖地的B/S架构来说,看上去似乎和Win95一样古老,很多新入行的,可能就没有见过经典的 ...

  8. C#限速下载网络文件

    代码: using System; using System.Collections.Concurrent; using System.Collections.Generic; using Syste ...

  9. C#定时执行

    代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; ...

  10. 基于Dubbo框架构建分布式服务(一)

    Dubbo是Alibaba开源的分布式服务框架,我们可以非常容易地通过Dubbo来构建分布式服务,并根据自己实际业务应用场景来选择合适的集群容错模式,这个对于很多应用都是迫切希望的,只需要通过简单的配 ...

随机推荐

  1. 小结event.target与this

    <!DOCTYPE html> <html> <head>     <meta charset="UTF-8">     <t ...

  2. 手写tomcat——netty版

    点击查看代码 package com.grady.diytomcat; import com.grady.diytomcat.handler.DiyNettyTomcatHandler; import ...

  3. 这里聊聊扫地机的 IOT 开发

    以下内容为本人的著作,如需要转载,请声明原文链接微信公众号「englyf」https://www.cnblogs.com/englyf/p/16663833.html 消费者使用扫地机通常的方式是通过 ...

  4. 《Java基础——方法的调用》

    Java基础--方法的调用     总结: 1. 在同一个类中-- 对于静态方法,其它的静态和非静态方法都可以直接通过"方法名"或者"类名.方法名"调用它. 对 ...

  5. kubernetes 调度器

    调度器 kube-scheduler 是 kubernetes 的核心组件之一,主要负责整个集群资源的调度功能,根据特定的调度算法和策略,将 Pod 调度到最优的工作节点上面去,从而更加合理.更加充分 ...

  6. PostgreSQL 创建数据库

    PostgreSQL 创建数据库可以用以下三种方式: 1.使用 CREATE DATABASE SQL 语句来创建. 2.使用 createdb 命令来创建. 3.使用 pgAdmin 工具. CRE ...

  7. 通过 Docker 部署 Redis 6.x 集群

    要点步骤总结: # 这里演示使用同一台主机上 # 创建各节点存储路径 mkdir -p /opt/redis/{7000,7001,7002,7003,7004,7005} # 创建各节点配置文件 c ...

  8. [CG从零开始] 3. 安装 pyassimp 库加载模型文件

    assimp 是一个开源的模型加载库,支持非常多的格式,还有许多语言的 binding,这里我们选用 assimp 的 python 的 binding 来加载模型文件.不过社区主要是在维护 assi ...

  9. 在vue中的form表单中下拉框中的数据来自数据库查询到的数据

    文章目录 1.实现的效果: 2.前端html代码 3.js中的代码 4.后端的方法 1.实现的效果: 增加一个新的类型到数据库 2.前端html代码 需要注意的部分:prop后边是表单中的字段 v-m ...

  10. Aspose.Words 操作 Word 画 EChart 图

    使用 Aspose.Words 插件在 Word 画 EChart 图 使用此插件可以画出丰富的 EChart 图,API 参考 https://reference.aspose.com/words/ ...