Coder Social home page Coder Social logo

silentsoul04 / uri Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lucasepe/uri

0.0 1.0 0.0 14 KB

A commandline tool to resolve URI Templates expressions as specified in RFC 6570.

License: BSD 3-Clause "New" or "Revised" License

Makefile 3.60% Go 96.40%

uri's Introduction

URI

         _            _  
o  / / _|     URI      |_ 
o / /   |_ Templates  _|

A commandline tool to resolve URI Templates expressions as specified in RFC 6570.

For a complete syntax reference check the RFC6570 specs here: https://tools.ietf.org/html/rfc6570#section-2.

Expressions are placeholders which are to be substituted by the values their variables reference.

http://example.org/~{username}/
http://example.org/dictionary/{term:1}/{term}
http://example.org/search{?q*,lang}

How to use uri

This tool takes a JSON as input data model containing the values โ€‹โ€‹of the variables. Example:

{
    "username": "scarlett",
    "term": "black widow",
    "q": {
        "a": "mars",
        "b": "jupiter"
    },
    "lang": "en"
}

You can pass this JSON as file using the -i flag:

$ uri -i data.json http://example.org/~{username}/{term:1}/{term}{?q*,lang}
http://example.org/~scarlett/b/black%20widow?q*

Or you can pipe it directly to the tool (and this the most interesting use case):

$ cat data.json | uri http://example.org/~{username}/{term:1}/{term}{?q*,lang}
http://example.org/~scarlett/b/black%20widow?q*

Using commandline pipes you can achieve tasks like this:

$ cat testdata/pets.json \
  | jq --raw-output '.pets[1] | {category: .species, year: .birthYear}' \
  | uri https://pets.api.com/{category}{?year} \
  | xargs curl

Installation Steps

In order to use the crumbs command, compile it using the following command:

go get -u github.com/lucasepe/uri

This will create the executable under your $GOPATH/bin directory.

Ready-To-Use Releases

If you don't want to compile the source code yourself, here you can find the executables for:

  • MacOS
  • Linux
  • Windows

Credits

uri was possible thanks to the Joshua Tacoma URI Template library.

uri's People

Contributors

lucasepe avatar

Watchers

 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.