Skip to content
/ urc Public
forked from alexfacciorusso/urc

Uniform Resource Creator. A class that helps user to create URLs to RESTful apis.

License

Notifications You must be signed in to change notification settings

KHTOOL/urc

 
 

Repository files navigation

Urc

JitPack Android Arsenal

Uniform Resource Creator. An Android (working for Java-generic) library that helps user to create URLs for RESTful apis.

The path syntax is taken from Slim framework, so it is in the form of /static/:argument.

Example

Urc myApi = Urc.with("https://my-api.com/v1");
myApi.fromEndpoint("/:firstArgument/try/:second")
     .addParameter("firstArgument", "first")
     .addParameter("second", 2)
     .addParameter("noListed", "hello")
     .build();

The resulting url will be: https://my-api.com/v1/first/try/2?noListed=hello

Note: The query parameter generation is enabled by default. It can be disabled by the .setQueryParametersEnabled(boolean) method in the UrcGenerator class.

Installation

As library

Simply checkout this repo and import the library in Android Studio.

As Gradle dependency

Follow instructions on https://jitpack.io/#alexfacciorusso/urc (go on that link and then click on "Get it" button near the latest release).

FAQ

#### Why this library uses two classes (Urc and UrcGenerator) to build the Url/Uri? Because the method Uri.with returns the "service" builder. The system allows to build several uris from a single service.

Example:

// This is our main service/api url.
Urc ourService = Urc.with("https://ourservice.com");

String listUrl = ourService.fromEndpoint("/list/:id")
    ...
    .build();
String createUrl = ourService.fromEndpoint("/create/:name")
    ...
    .build();

License

Created by Alex Facciorusso and licensed under Apache 2.0.

Please read the included LICENSE.txt file for the full terms and conditions.

About

Uniform Resource Creator. A class that helps user to create URLs to RESTful apis.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%