curl

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 6 Imported by: 0

README

go version license version

curl

curl is a lightweight package for rendering http request and response from curl string with Go

Documentation

Install

go get github.com/erfanmomeniii/curl

Next, include it in your application:

import "github.com/erfanmomeniii/curl"

Quick Start

The following example demonstrates how to use this package for generating request and response from curl:

package main

import (
	"fmt"
	"github.com/erfanmomeniii/curl"
)

func main() {
	c, _ := curl.New("curl -H \"Test1:no\" -H \"Test2:yes\" -d \"User=foobar\" www.google.com")

	request := c.Request()
	response, _ := c.Response()

	fmt.Println(request, response)
}

Contributing

Pull requests are welcome. For changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotValidError = errors.New("curl is not valid")
)

Functions

This section is empty.

Types

type Content

type Content struct {
	Url    *url.URL
	Option Option
}

type Curl

type Curl struct {
	Content
	HttpCommunication
}

func New

func New(curl string) (*Curl, error)

func (*Curl) Request

func (c *Curl) Request() *http.Request

func (*Curl) Response

func (c *Curl) Response() (*http.Response, error)

type HttpCommunication

type HttpCommunication interface {
	Request() (*http.Request, error)
	Response() (*http.Response, error)
}

type Option

type Option map[string]string

type Stack

type Stack []string

func PopStack

func PopStack(st Stack) Stack

func PushStack

func PushStack(st Stack, s string) Stack

Jump to

Keyboard shortcuts

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