// 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. HCNP Routing&Switching之DHCP安全

    前文我们了解了MAC地址防漂移技术,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/16632239.html:今天我们来了解下DHCP安全相关话题: 回顾DHC ...

  2. openstack中Neutron组件简解

    一.Neutron概述 Neutron 的设计目标是实现"网络即服务(Networking as a Service)".为了达到这一目标,在设计上遵循了基于 SDN 实现网络虚拟 ...

  3. JDK 自带的服务发现框架 ServiceLoader 好用吗?

    请点赞关注,你的支持对我意义重大. Hi,我是小彭.本文已收录到 Github · AndroidFamily 中.这里有 Android 进阶成长知识体系,有志同道合的朋友,关注公众号 [彭旭锐] ...

  4. 常用的工具函数助力JavaScript高效开发

    前言 日常开发中,面对各种不同的需求,我们经常会用到以前开发过的一些工具函数,把这些工具函数收集起来,将大大提高我们的开发效率. 1.校验数据类型 export const typeOf = func ...

  5. Awvs+nessus docker版本

    awvs-nessus 拉取镜像 docker pull leishianquan/awvs-nessus:v2 启动 docker run --name awvs-nessus -it -d -p ...

  6. 从 Hadoop 到云原生, 大数据平台如何做存算分离

    Hadoop 的诞生改变了企业对数据的存储.处理和分析的过程,加速了大数据的发展,受到广泛的应用,给整个行业带来了变革意义的改变:随着云计算时代的到来, 存算分离的架构受到青睐,企业开开始对 Hado ...

  7. winfrom杀死进程及关闭进程

    ProcessStartInfo process = new ProcessStartInfo(); process.FileName = AppDomain.CurrentDomain.BaseDi ...

  8. .Net 不受 EAR 的约束

    NPUlrk :https://github.com/NPUlrk  同学在 dotnet/runtime 仓库提出了一共问题: https://github.com/dotnet/runtime/d ...

  9. 一文搞懂容器运行时 Containerd

    文章转载自:https://www.qikqiak.com/post/containerd-usage/ 在学习 Containerd 之前我们有必要对 Docker 的发展历史做一个简单的回顾,因为 ...

  10. Centos7安装redash

    一.更改yum国内源: (1)cd /etc/yum.repos.d/ sudo yum install wget (2)备份:sudo mv /etc/yum.repos.d/CentOS-Base ...