Wrapper to easily generate "X-Request-Auth" header for Mesh sites in golang.

hawk mesh go ๐ŸŒŸ

๐Ÿ’ฌ Description

Wrapper to easily generate "X-Request-Auth" header for Mesh sites in golang. Based on hawk-go.

Getting Started

Import the module :

import (
    "github.com/ibadus/hawk-mesh-go"
)

๐Ÿค” Usage :

headers, err := hawk.GenerateHeaders("GET", url, key, secret)
headers, err := hawk.GenerateHeaders("PUT", url, key, secret)
headers, err := hawk.GenerateHeadersWithPayload("POST", url, key, secret, string(payload))
headers, err := hawk.GenerateHeadersWithPayload("PUT", url, key, secret, string(payload))

You can find key, secret, apikey in the Mesh-Keys.txt click here. Python solution also available in the repo linked.

๐Ÿ”” Examples :

Create a GET "X-Request-Auth" header

key := "f2188a5b06"
secret := "8bb6bd51c83f2ec9821e1bda5c77b25b"
url := "https://prod.jdgroupmesh.cloud/stores/jdsportsfr/" + "..."

headers, err := hawk.GenerateHeaders("GET", url, key, secret)
if err != nil {
	return
}
hawkHeader := map[string]string{"X-Request-Auth": headers}

Create a POST "X-Request-Auth" header

key := "f2188a5b06"
secret := "8bb6bd51c83f2ec9821e1bda5c77b25b"
url := "https://prod.jdgroupmesh.cloud/stores/jdsportsfr/" + "..."
payload := []byte(fmt.Sprintf(`
    "Value1": "%s",
    "Value2": "%s",
`, "v1", "v2"))

headers, err := hawk.GenerateHeadersWithPayload("POST", url, key, secret, string(payload))
if err != nil {
	return
}
hawkHeader := map[string]string{"X-Request-Auth": headers}

Create a PUT "X-Request-Auth" header

key := "f2188a5b06"
secret := "8bb6bd51c83f2ec9821e1bda5c77b25b"
url := "https://prod.jdgroupmesh.cloud/stores/jdsportsfr/" + "..."
payload := []byte(fmt.Sprintf(`
    "Value1": "%s",
    "Value2": "%s",
`, "v1", "v2"))

headers, err := hawk.GenerateHeadersWithPayload("PUT", url, key, secret, string(payload))
if err != nil {
	return
}
hawkHeader := map[string]string{"X-Request-Auth": headers}

Let's test

package main

import (
	"fmt"
	"github.com/ibadus/hawk-mesh-go"
)

func main() {
	fmt.Println("Let's try")
	key := "f2188a5b06"
	secret := "8bb6bd51c83f2ec9821e1bda5c77b25b"
	url := "https://prod.jdgroupmesh.cloud/stores/jdsportsfr/"

	headers, err := hawk.GenerateHeaders("GET", url, key, secret)
	if err != nil {
		return
	}
	fmt.Println("X-Request-Auth:", headers)
}
Similar Resources

Swagger-go-chi - Generate a go-chi server from swagger

swagger-go-chi Install go install github.com/cugu/swagger-go-chi@main Run swagge

Nov 5, 2022

Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.

Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.

#1 Golang live reload and task runner Content - โญ๏ธ Top Features - ๐Ÿ’ƒ๐Ÿป Get started - ๐Ÿ“„ Config sample - ๐Ÿ“š Commands List - ๐Ÿ›  Support and Suggestions

Dec 31, 2022

Golang ๅพฎๆœๅŠกๆก†ๆžถ๏ผŒๆ”ฏๆŒ grpc/http๏ผŒๆ”ฏๆŒๅคš็งๆณจๅ†Œไธญๅฟƒ etcd,consul,mdns ็ญ‰

ไธ€ไธช็”จไบŽๆž„ๅปบๅˆ†ๅธƒๅผ็ณป็ปŸ็š„ๅทฅๅ…ท้›†ๆˆ–่€…่ฝปๆก†ๆžถ๏ผŒๆ”ฏๆŒ grpc ๅ’Œ http ๏ผŒๆ”ฏๆŒๅคš็งๆณจๅ†Œไธญๅฟƒ consul ๏ผŒetcd , mdns ็ญ‰ใ€‚

Nov 30, 2022

goTempM is a full stack Golang microservices sample application built on top of the Micro platform.

goTempM is a full stack Golang microservices sample application built on top of the Micro platform.

goTempM is a full stack Golang microservices sample application built on top of the Micro platform.

Sep 24, 2022

Generates Golang client and server based on OpenAPI2 (swagger) definitions

Generates Golang client and server based on OpenAPI2 (swagger) definitions

ExperienceOne Golang APIKit ExperienceOne Golang APIKit Overview Requirements Installation Usage Generate standard project structure Define the API wi

Aug 9, 2022

Kratos is a microservice-oriented governance framework implements by golang

Kratos is a microservice-oriented governance framework implements by golang

Kratos is a microservice-oriented governance framework implements by golang, which offers convenient capabilities to help you quickly build a bulletproof application from scratch.

Dec 27, 2022

RPC explained by writing simple RPC framework in 300 lines of pure Golang.

Simple GoRPC Learning RPC basic building blocks by building a simple RPC framework in Golang from scratch. RPC In Simple Term Service A wants to call

Dec 17, 2022

Modern microservice web framework of golang

Modern microservice web framework of golang

gogo gogo is an open source, high performance RESTful api framework for the Golang programming language. It also support RPC api, which is similar to

May 23, 2022

UPBit Auto Trading with OpenAPI Golang Module

Go-Bit! UPBit Auto Trading System with OpenAPI ์ด ๋ ˆํฌ์ง€ํ† ๋ฆฌ๋Š” upbit๋ฅผ ์œ„ํ•œ ์ž๋™๋งค๋งค ํ”„๋กœ๊ทธ๋žจ์„ ๊ฐœ๋ฐœํ•˜๊ธฐ ์œ„ํ•ด ์ œ๊ณตํ•˜๋Š” go module์ž…๋‹ˆ๋‹ค. Features ๊ตฌํ˜„ ์ž‘์—… ์ง„ํ–‰์ƒํ™ฉ Sample Code Template shiel

Jun 27, 2022
EaseMesh is a service mesh that is compatible with the Spring Cloud ecosystem.
EaseMesh is a service mesh that is compatible with the Spring Cloud ecosystem.

A service mesh implementation for connecting, control, and observe services in spring-cloud.

Jan 4, 2023
The Consul API Gateway is a dedicated ingress solution for intelligently routing traffic to applications running on a Consul Service Mesh.

The Consul API Gateway is a dedicated ingress solution for intelligently routing traffic to applications running on a Consul Service Mesh.

Dec 14, 2022
Meshery, the service mesh management plane
Meshery, the service mesh management plane

Meshery is the multi-service mesh management plane offering lifecycle, configuration, and performance management of service meshes and their workloads.

Jan 5, 2023
Use eBPF to speed up your Service Mesh like crossing an Einstein-Rosen Bridge.

merbridge Use eBPF to speed up your Service Mesh like crossing an Einstein-Rosen Bridge. Usage Install You just only need to run the following command

Jan 1, 2023
Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily.
Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily.

Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily.

Dec 30, 2022
Automatically generate tags for golang struct.

gotag is a command tool that can automatically generate tags for golang struct. Quick start Install gotag go install github.com/sycki/gotag@latest Pr

Feb 12, 2022
Fastglue is an opinionated, bare bones wrapper that glues together fasthttp and fasthttprouter to act as a micro HTTP framework.

fastglue Overview fastglue is an opinionated, bare bones wrapper that glues together fasthttp and fasthttprouter to act as a micro HTTP framework. It

Jun 14, 2022
Generate plantuml diagrams from go source files or directories
Generate plantuml diagrams from go source files or directories

go-plantuml go-plantuml generates plantuml diagrams from go source files or directories. Installation go get -u github.com/bykof/go-plantuml Please co

Jan 9, 2023
A library to generate go models from given json files
A library to generate go models from given json files

generate A library to generate go models from given json files Requirements Go 1

May 18, 2022
White Matrix Micro Service Generate CLI Tool

micro-service-gen-tool White Matrix Micro Service Generate CLI Tool usage templa

Jan 5, 2022