methods

package
v0.0.0-...-fcb0c04 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Contenttypes = map[string]string{
	"html":  "text/html",
	"js":    "application/json",
	"xml":   "application/xml",
	"plain": "text/plain",
}

Contenttypes are used in Place for ctypes for sending requests

Functions

func BasicRequestWithBody

func BasicRequestWithBody(c *cli.Context, method string) (string, error)

BasicRequestWithBody sends put|patch|post|delete requests

func GenerateDocs

func GenerateDocs(output string, exportPathfile string, servePort int, isOpenBrowser bool, templatedir string) error

GenerateDocs generates the Documentation site from the hoppscotch-collection.json

func Getbasic

func Getbasic(c *cli.Context) (string, error)

Getbasic sends a simple GET request to the url with any potential parameters like Tokens or Basic Auth

func ProcessCollection

func ProcessCollection(jsonArr []Collection) (string, error)

ProcessCollection parses the Collection struct and execute the said requests

Types

type AuthType

type AuthType struct {
	Key   string `json:"key"`
	AddTo string `json:"addTo"`
	Value string `json:"value"`

	// value enum => none,inherit,bearer
	AuthType string `json:"authType"`

	AuthActive bool `json:"authActive"`

	// JWT Token on auth type bearer
	Token string `json:"token"`

	// for basic auth
	Username string `json:"username"`
	Password string `json:"password"`
}

type Body

type Body struct {
	Body        interface{} `json:"body"`
	ContentType string      `json:"contentType"`
}

func (*Body) UnmarshalJSON

func (b *Body) UnmarshalJSON(data []byte) error

type BodyParams

type BodyParams struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

BodyParams include the Body Parameters

type Collection

type Collection struct {
	Version int `json:"v"`
	// Name of the Whole Collection
	Name string `json:"name"`
	// Folders JSON Type
	// Folders []Folders `json:"folders"`
	Folders []Collection `json:"folders"`
	// Requests inside the Collection
	Requests []Requests `json:"requests"`

	// Set Data into Collection
	Property FolderProperties `json:"data"`

	// for Folder v2
	Headers []Headers `json:"headers"`
	Auth    AuthType  `json:"auth"`
}

Collection hold the structure of the basic `postwoman-collection.json`

func ParseCollection

func ParseCollection(data []byte) ([]Collection, error)

func ReadCollection

func ReadCollection(filename string) ([]Collection, error)

ReadCollection reads the `hoppScotch-collection.json` File and returns a the Loaded Collection Struct

func (*Collection) UnmarshalJSON

func (c *Collection) UnmarshalJSON(data []byte) error

type ExampleResponse

type ExampleResponse struct {
	Status   int
	Name     string
	Response string
}

type FileTrunk

type FileTrunk struct{ bytes.Buffer }

FileTrunk handles the buffer for generated README.md File

func (*FileTrunk) IsDir

func (f *FileTrunk) IsDir() bool

IsDir checks if True

func (*FileTrunk) ModTime

func (f *FileTrunk) ModTime() time.Time

ModTime holds creation time of File

func (*FileTrunk) Mode

func (f *FileTrunk) Mode() os.FileMode

Mode holds the file Mode

func (*FileTrunk) Name

func (f *FileTrunk) Name() string

Name holds the FileName, here README.md

func (*FileTrunk) Size

func (f *FileTrunk) Size() int64

Size holds the size of the File

func (*FileTrunk) Sys

func (f *FileTrunk) Sys() interface{}

Sys - I have no idea

type FolderProperties

type FolderProperties struct {
	Auth    AuthType  `json:"auth"`
	Headers []Headers `json:"headers"`
}

func (*FolderProperties) UnmarshalJSON

func (f *FolderProperties) UnmarshalJSON(data []byte) error

type Folders

type Folders struct {
	// Folder name
	Name string `json:"name"`
	// Requests inside the Folder
	Requests []Requests `json:"requests"`

	// Set Data into Collection
	Property FolderProperties `json:"data"`
}

Folders can be organized to Folders

type Headers

type Headers struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Headers are the Request Headers

type RequestVariable

type RequestVariable struct {
	Key      string            `json:"key"`
	Value    string            `json:"value"`
	Examples []ExampleResponse `json:"-"`
}

func (*RequestVariable) UnmarshalJSON

func (b *RequestVariable) UnmarshalJSON(data []byte) error

type RequestVariables

type RequestVariables []RequestVariable

func (RequestVariables) GetRequestVariables

func (r RequestVariables) GetRequestVariables() []RequestVariable

type Requests

type Requests struct {
	// Base URL of the Request
	URL string `json:"endpoint"`
	// Path is the enpoint path
	// URL+PATH = Full URL
	Path string `json:"path"`
	// Request Method - GET,POST,PUT,PATCH,DELETE
	Method string `json:"method"`
	// Authentication Type - Bearer Token or Basic Auth
	Auth AuthType `json:"auth"`
	// Username for Basic Auth
	User string `json:"httpUser"`
	// Password for Basic Auth
	Pass              string `json:"httpPassword"`
	PasswordFieldType string `json:"passwordFieldType"`
	// Request Headers if any- Key,Value pairs
	Headers []Headers `json:"headers"`
	// Params for Get Requests
	Params []interface{} `json:"params"`
	// Body Params for POST requests and forth
	Bparams []interface{} `json:"bodyParams"`
	// Raw Input. Not Formatted JSON
	RawParams string `json:"rawParams"`
	// If RawInputs are used or Not
	RawInput bool `json:"rawInput"`
	// Content Type of Request
	Body             Body              `json:"body"`
	RequestType      string            `json:"requestType"`
	PreRequestScript string            `json:"preRequestScript"`
	TestScript       string            `json:"testScript"`
	RequestVariable  []RequestVariable `json:"requestVariables"`
	// Label of Collection
	Label string `json:"label"`
	// Name of the Request
	Name string `json:"name"`
	// Number of Collection
	Collection int `json:"collection"`
}

Requests are the Request Model in JSON

func (*Requests) PrepareText

func (r *Requests) PrepareText()

Jump to

Keyboard shortcuts

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