GithubHelp home page GithubHelp logo

lubyruffy / http2curl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moul/http2curl

0.0 0.0 0.0 235 KB

:triangular_ruler: Convert Golang's http.Request to CURL command line

Home Page: https://manfred.life/http2curl

License: Other

Go 39.17% Makefile 59.79% JavaScript 1.05%

http2curl's Introduction

http2curl

๐Ÿ“ Convert Golang's http.Request to CURL command line

go.dev reference License GitHub release Docker Metrics Made by Manfred Touron

Go Release PR GolangCI codecov Go Report Card CodeFactor

To do the reverse operation, check out mholt/curl-to-go.

Example

import (
    "http"
    "moul.io/http2curl"
)

data := bytes.NewBufferString(`{"hello":"world","answer":42}`)
req, _ := http.NewRequest("PUT", "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu", data)
req.Header.Set("Content-Type", "application/json")

command, _ := http2curl.GetCurlCommand(req)
fmt.Println(command)
// Output: curl -X PUT -d "{\"hello\":\"world\",\"answer\":42}" -H "Content-Type: application/json" http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu

Install

go get moul.io/http2curl

Usages

License

ยฉ 2019-2021 Manfred Touron

Licensed under the Apache License, Version 2.0 (LICENSE-APACHE) or the MIT license (LICENSE-MIT), at your option. See the COPYRIGHT file for more details.

SPDX-License-Identifier: (Apache-2.0 OR MIT)

http2curl's People

Contributors

moul avatar renovate-bot avatar dependabot[bot] avatar dzalevski avatar elliotchance avatar hzakher avatar jaytaylor avatar richardsonlima avatar stevenacoffman avatar th3whit3d3ath avatar xwjdsh avatar moul-bot avatar psaffrey-illumina avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.