restlib

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 14 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHeaderParam

func GetHeaderParam(r *http.Request, key string) string

func GetQueryParam

func GetQueryParam(r *http.Request, key string) string

func GetURLParam

func GetURLParam(r *http.Request, key string) string

func SendHTTPResponse

func SendHTTPResponse(w http.ResponseWriter, httpStatus int, responses ...interface{})

SendHTTPResponse sends the http response to the client

func SetHeaders

func SetHeaders(w http.ResponseWriter, headerMap http.Header)

SetHeaders sets the headers in response

Types

type HTTPResult

type HTTPResult struct {
	HTTPResponse *http.Response
	Body         []byte
	Response     interface{}
}

HTTPResult is the result return by the library

func DoHTTPRequest

func DoHTTPRequest(ctx context.Context, client *http.Client, method string,
	urlString string, body interface{}, required []string,
	okResponse interface{}, errorResponse interface{}) (*HTTPResult, error)

DoHTTPRequest returns HTTPResult

func (*HTTPResult) Error

func (r *HTTPResult) Error() string

Jump to

Keyboard shortcuts

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