postman

package
v0.0.0-...-55178a5 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SubstVars

func SubstVars(templ string, vars map[string]string) (string, error)

SubstVars subsitutes variables in a string

Types

type Body

type Body struct {
	Mode string
	Raw  string
}

Body represents a body

type Collection

type Collection struct {
	Info CollectionInfo
	Item []CollectionItem
	Auth CollectionAuth
}

Collection represents a collection of requests

func NewCollection

func NewCollection(name string, items []CollectionItem, auth *CollectionAuth) *Collection

NewCollection returns a new Collection

func (*Collection) ItemWithName

func (c *Collection) ItemWithName(name string) *CollectionItem

ItemWithName gets an item with a particular name

type CollectionAuth

type CollectionAuth struct {
	Type   string
	Bearer CollectionBearerAuth
}

CollectionAuth defines the authentication headers for the collection

type CollectionBearerAuth

type CollectionBearerAuth struct {
	Key   string
	Value string
	Type  string
}

CollectionBearerAuth represents bearer token auth

type CollectionInfo

type CollectionInfo struct {
	ID     string `json:"_postman_id"`
	Name   string
	Schema string
}

CollectionInfo represents info about a collection

type CollectionItem

type CollectionItem struct {
	Name     string
	Request  Request
	Response []Response
}

CollectionItem represents a request/response in a collection

type EnvMeta

type EnvMeta struct {
	VariableScope string `json:"_postman_variable_scope"`
	ExportedAt    string `json:"_postman_exported_at"`
	ExportedUsing string `json:"_postman_exported_using"`
}

EnvMeta defines the metadata for an environment

type Environment

type Environment struct {
	EnvMeta
	ID     string
	Name   string
	Values []Variable
}

Environment defines an execution environment

func EnvironmentFromFile

func EnvironmentFromFile(filepath string) (*Environment, error)

EnvironmentFromFile creates an environment from a file

func (*Environment) VariableMap

func (e *Environment) VariableMap() map[string]string

VariableMap returns a msp[string]string of the environment's variables

type Header struct {
	Key   string
	Name  string
	Value string
	Type  string
}

Header represents a header

type Request

type Request struct {
	Method string
	Header []Header
	Body   Body `json:"Body,omitempty"`
	URL    URL
}

Request represents a request to the endpoint

func RequestFromHTTP

func RequestFromHTTP(r *http.Request) (*Request, error)

RequestFromHTTP converts an http request to a postman request

func (*Request) ToHTTPRequest

func (r *Request) ToHTTPRequest(vars map[string]string) *http.Request

ToHTTPRequest converts a postman request to an http request

type Response

type Response struct {
	Mode   string
	Raw    string
	Status int
}

Response describes a response

func (*Response) InflateEnvironmentVariables

func (r *Response) InflateEnvironmentVariables(vars map[string]string) (*Response, error)

InflateEnvironmentVariables for the Response

func (*Response) ToInterface

func (r *Response) ToInterface(out interface{}) error

ToInterface unmarshals a response into an interface

type URL

type URL struct {
	Raw  string
	Host []string
	Port string
	Path []string
}

URL represents a URL

type Variable

type Variable struct {
	Key         string
	Value       string
	Type        string
	Description string
	Enabled     bool
}

Variable defines a defined variable value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳