bridge

package
v0.0.0-...-98639ff Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFileRequestBody

func CreateFileRequestBody(path, contentType string, params map[string]string) (*bytes.Buffer, string, error)

CreateFileRequestBody create a multi-part form data. We assume all endpoints handling files are receicing a single file with form name "file_data"

func ToH

func ToH(z interface{}) map[string]interface{}

ToH is a convenience wrapper create a json for any object

Types

type Bridge

type Bridge struct {
	Client     http.Client
	Connection *Connection
	Verbose    bool
}

func NewBridge

func NewBridge() *Bridge

NewBridge creates a new Bridge

func (Bridge) BuildDataRequest

func (b Bridge) BuildDataRequest(method, url string, data map[string]interface{}) *http.Request

BuildDataRequest creates a request

func (*Bridge) Delete

func (b *Bridge) Delete(url string, modifiers ...RequestModifier) *ParsedResponse

Delete creates, sends a DELETE request and fetches the response

func (*Bridge) FormatRequest

func (b *Bridge) FormatRequest(r *http.Request) string

FormatRequest pretty-formats a request and returns it as a string

func (*Bridge) Get

func (b *Bridge) Get(url string, modifiers ...RequestModifier) *ParsedResponse

Get creates, sends a GET request and fetches the response

func (*Bridge) Patch

func (b *Bridge) Patch(url string, data map[string]interface{}, modifiers ...RequestModifier) *ParsedResponse

Patch creates, sends a PATCH request and fetches the response

func (*Bridge) PlayRequest

func (b *Bridge) PlayRequest(r *http.Request) *ParsedResponse

PlayRequest will send the request to the router and fetch the response

func (*Bridge) Post

func (b *Bridge) Post(url string, data map[string]interface{}, modifiers ...RequestModifier) *ParsedResponse

Post creates, sends a POST request and fetches the response

func (*Bridge) Put

func (b *Bridge) Put(url string, data map[string]interface{}, modifiers ...RequestModifier) *ParsedResponse

Put creates, sends a PUT request and fetches the response

func (*Bridge) ToH

func (b *Bridge) ToH(z interface{}) map[string]interface{}

ToH is a convenience wrapper create a json for any object

func (*Bridge) Upload

func (b *Bridge) Upload(url string, filename string, contentType string, modifiers ...RequestModifier) (*ParsedResponse, error)

func (*Bridge) UploadWithParameters

func (b *Bridge) UploadWithParameters(url string, filename string, contentType string, params map[string]string, modifiers ...RequestModifier) (*ParsedResponse, error)

type Connection

type Connection struct {
	Email       string
	URL         string
	Credentials app.AuthResponse
}

func NewConnection

func NewConnection() Connection

func (*Connection) Modify

func (c *Connection) Modify(r *http.Request)

func (*Connection) RequireCredentials

func (c *Connection) RequireCredentials()

func (*Connection) RequireEmail

func (c *Connection) RequireEmail()

func (*Connection) RequireURL

func (c *Connection) RequireURL()

type H

type H map[string]interface{}

H is a neat alias

type ParsedResponse

type ParsedResponse struct {
	Response *http.Response
}

func (*ParsedResponse) Close

func (pr *ParsedResponse) Close()

func (*ParsedResponse) DecodeJSON

func (pr *ParsedResponse) DecodeJSON(target interface{}) error

func (*ParsedResponse) OK

func (pr *ParsedResponse) OK() bool

func (*ParsedResponse) Plain

func (pr *ParsedResponse) Plain() string

func (*ParsedResponse) PrintCode

func (pr *ParsedResponse) PrintCode()

type RequestModifier

type RequestModifier interface {
	Modify(r *http.Request)
}

Jump to

Keyboard shortcuts

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