resthttp

package
Version: v0.0.0-...-3dd77f1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package resthttp is a HTTP handler for making request and return response data

All data should not parse to database directly, and must be generated as signature at first

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendRequest

func SendRequest(url, content, cors string, cHeader *[]HttpHeader) string

SendRequest : Send request with no authorize method

func SendRequestWithBasicAndToken

func SendRequestWithBasicAndToken(url, content, cors, uname, pwd, tokenHeader, tokenStr string, cHeader *[]HttpHeader) string

SendRequestWithBasicAndToken : Send request with username, password and token

func SendRequestWithBasicAuth

func SendRequestWithBasicAuth(url, content, cors, uname, pwd string, cHeader *[]HttpHeader) string

SendRequestWithBasicAuth : Send request with username and password

func SendRequestWithTokenAuth

func SendRequestWithTokenAuth(url, content, cors, tokenHeader, tokenStr string, cHeader *[]HttpHeader) string

SendRequestWithTokenAuth : Send request with token

func SetCORS

func SetCORS(allows string) error

SetCORS : Set CORS which domain will be allow to fetch

func SetContentType

func SetContentType(mime string) error

SetContentType : Define content type for making request

func SetCustomHeader

func SetCustomHeader(n, v string, override bool) error

SetCustomHeader : Allow user define custom headers by theirselves

THIS ACTION MAY CAUSE REQUEST FAILED IF DEFINED INCORRECTLY

Types

type Auth

type Auth interface {
	GetJSON() string //Get JSON formatted authorize data
}

Auth : Getter of authorization

Authorization interface

type HttpHeader

type HttpHeader struct {
	Name  string
	Value string
}

HttpHeader : Contains HTTP(S) header's name and value

Jump to

Keyboard shortcuts

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