Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

HTTP Request snippet generator for many languages & libraries

License

NotificationsYou must be signed in to change notification settings

confluentinc/httpsnippet

 
 

Repository files navigation

HTTP Request snippet generator formany languages & tools including:cURL,HTTPie,Javascript,Node,C,Java,PHP,Objective-C,Swift,Python,Ruby,C#,Go,OCaml andmore!

Relies on the popularHAR format to import data and describe HTTP calls.

See it in action on companion service:APIembed

Build StatusDownloads

Install

# to use in clinpm install --global httpsnippet# to use as a modulenpm install --save httpsnippet

Usage

  Usage: httpsnippet [options] <file>  Options:    -h, --help                output usage information    -V, --version             output the version number    -t, --target <target>     target output    -c, --client [client]     target client library    -o, --output <directory>  write output to directory
Example

process single file:example.json inHAR Request Object format, or fullHAR log format:

httpsnippet example.json --target node --client unirest --output ./snippets
$ tree snippetssnippets/└── example.js

process multiple files:

httpsnippet ./*.json --target node --client request --output ./snippets
$ tree snippets/snippets/├── endpoint-1.js├── endpoint-2.js└── endpoint-3.js

API

HTTPSnippet(source)

source

RequiredType:object

Name ofconversion target

varHTTPSnippet=require('httpsnippet');varsnippet=newHTTPSnippet({method:'GET',url:'http://mockbin.com/request'});

convert(target [, options])

target

RequiredType:string

Name ofconversion target

options

Type:object

Target options,seewiki for details

varHTTPSnippet=require('httpsnippet');varsnippet=newHTTPSnippet({method:'GET',url:'http://mockbin.com/request'});// generate Node.js: Native outputconsole.log(snippet.convert('node'));// generate Node.js: Native output, indent with tabsconsole.log(snippet.convert('node',{indent:'\t'}));

convert(target [, client, options])

target

RequiredType:string

Name ofconversion target

client

Type:string

Name of conversion targetclient library

options

Type:object

Target options,seewiki for details

varHTTPSnippet=require('httpsnippet');varsnippet=newHTTPSnippet({method:'GET',url:'http://mockbin.com/request'});// generate Shell: cURL outputconsole.log(snippet.convert('shell','curl',{indent:'\t'}));// generate Node.js: Unirest outputconsole.log(snippet.convert('node','unirest'));

addTarget(target)

target

RequiredType:object

Representation of aconversion target. Can use this to use targets that are not officially supported.

constcustomLanguageTarget=require('httpsnippet-for-my-lang');HTTPSnippet.addTarget(customLanguageTarget);

addTargetClient(target, client)

target

RequiredType:string

Name ofconversion target

client

RequiredType:object

Representation of aconversion target client. Can use this to use target clients that are not officially supported.

constcustomClient=require('httpsnippet-for-my-node-http-client');HTTPSnippet.addTargetClient('node',customClient);

Documentation

At the heart of this module is theHAR Format as the HTTP request description format, please review some of the sample JSON HAR Request objects intest fixtures, or read theHAR Docs for more details.

For detailed information on each target, please review thewiki.

Bugs and feature requests

Have a bug or a feature request? Please first read theissue guidelines and search for existing and closed issues. If your problem or idea is not addressed yet,please open a new issue.

Contributing

Please read through ourcontributing guidelines. Included are directions for opening issues, coding standards, and notes on development.

For info on creating new conversion targets, please review thisguideline

Moreover, if your pull request contains JavaScript patches or features, you must include relevant unit tests.

Editor preferences are available in theeditor config for easy use in common text editors. Read more and download plugins athttp://editorconfig.org.

Versioning

For transparency into our release cycle and in striving to maintain backward compatibility, this project is maintained under the Semantic Versioning guidelines. Sometimes we screw up, but we'll adhere to these rules whenever possible.

Releases will be numbered with the following format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backward compatibilitybumps the major while resetting minor and patch
  • New additions without breaking backward compatibilitybumps the minor while resetting the patch
  • Bug fixes and misc changesbumps only the patch

For more information on SemVer, please visithttp://semver.org/.

License

MIT ©Kong

About

HTTP Request snippet generator for many languages & libraries

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript99.9%
  • Dockerfile0.1%

[8]ページ先頭

©2009-2025 Movatter.jp