-
-
Notifications
You must be signed in to change notification settings - Fork 167
/
index.html
62 lines (54 loc) · 2.84 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
<title>curl-to-Go: Convert curl commands to Go code</title>
<meta charset="utf-8">
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('./sw.js').then(function(reg) {
console.log('Successfully registered service worker', reg);
}).catch(function(err) {
console.warn('Error whilst registering service worker', err);
})
}
</script>
<script src="resources/js/jquery.min.js"></script>
<script src="resources/js/highlight.pack.js"></script>
<script src="resources/js/common.js"></script>
<script src="https://mholt.github.io/json-to-go/resources/js/json-to-go.js"></script>
<script src="resources/js/curl-to-go.js"></script>
<script src="resources/js/gofmt.js" async></script>
<link rel="stylesheet" href="resources/css/color-brewer.css">
<link rel="stylesheet" href="resources/css/common.css">
</head>
<body>
<header>
<h1>curl-to-Go</h1>
<h2>Instantly convert <a href="http://curl.haxx.se/">curl</a> commands to <a href="https://golang.org/">Go</a> code</h2>
<p>
This tool turns a curl command into Go code. (To do the reverse, check out <a href="https://github.com/moul/http2curl">moul/http2curl</a>.) Currently, it knows the following options: -d/--data, -H/--header, -I/--head, -u/--user, --url, and -X/--request. It also understands JSON content types (see <a href="https://mholt.github.io/json-to-go">JSON-to-Go</a>). If the content type is application/x-www-form-urlencoded then it will convert the data to <a href="https://pkg.go.dev/net/url#Values">Values</a> (same as <a href="https://pkg.go.dev/net/http#Client.PostForm">PostForm</a>). Feel free to <a href="https://github.com/mholt/curl-to-go">contribute on GitHub</a>!
</p>
<p class="examples">
<a href="javascript:" id="example1">Example 1</a> ·
<a href="javascript:" id="example2">Example 2</a> ·
<a href="javascript:" id="example3">Example 3</a> ·
<a href="javascript:" id="example4">Example 4</a> ·
<a href="javascript:" id="example5">Example 5</a> ·
<a href="javascript:" id="example6">Example 6</a>
</p>
</header>
<main>
<textarea id="input" rows="4" placeholder="Paste curl here"></textarea>
<div class="copy-div">
<a href="javascript:" type="button" onclick="copyCode()">Copy to clipboard</a>
</div>
<div id="output"></div>
</main>
<p>
Note: http.DefaultClient will follow redirects by default, whereas curl does not without the <code>--location</code> flag. Since reusing the HTTP client is good Go practice, this tool does not attempt to configure the HTTP client for you.
</p>
<footer>
© <script>document.write(new Date().getFullYear());</script> Matt Holt - <a href="https://github.com/mholt/curl-to-go">View on GitHub</a> - <a id="dark" href="javascript:">Dark mode</a>
</footer>
</body>
</html>