httputil

package
v0.24.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CORS-related constants.
	CorsAllowOrigin  = "Access-Control-Allow-Origin"
	OriginAll        = "*"
	CorsAllowMethods = "Access-Control-Allow-Methods"
	ReqOptions       = "OPTIONS"
	CorsAllowHeaders = "Access-Control-Allow-Headers"
	CorsHeaders      = "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization"
)

Variables

This section is empty.

Functions

func CreateTLSHTTPClient

func CreateTLSHTTPClient(caCertPEM string) (*http.Client, error)

CreateTLSHTTPClient provides a basic http client prepared with a trusted CA cert

func EnableCORS

func EnableCORS(resp http.ResponseWriter, req *http.Request) bool

EnableCORS Allows Tenscan and WalletExtension APIs to serve other web apps via CORS.

func ExecuteHTTPReq

func ExecuteHTTPReq(client *http.Client, req *http.Request) ([]byte, error)

ExecuteHTTPReq executes an HTTP request: * returns an error if request fails or if the response code was outside the range 200-299 * returns response body as bytes if there was a response body

func PostDataJSON

func PostDataJSON(url string, data []byte) (int, []byte, error)

PostDataJSON sends a JSON payload to the given URL and returns the status, response body, and any error encountered.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL