Webwire command-line Interface
Webwire is a contract-first API system which features an interface description language a network protocol and code generator for both servers and clients.
This repository contains the the command-line interface used to validate Webwire IDL files and generate code and documentation.
To learn more about webwire in general please visit the documentation repository webwire/webwire-docs.
Example
The following example assumes a Rust server and a TypeScript client. Webwire is by no means limited to those two but those languages show the potential of webwire best.
Given the following IDL file:
webwire 1.0;
struct HelloRequest {
name: String,
}
struct HelloResponse {
message: String,
}
service Hello {
hello: HelloRequest -> HelloResponse
}
The server and client files can be generated using the code generator:
A Rust server implementation for the given code would look like this:
use SocketAddr;
use
use Server;
use ; // this is the generated code
async = from;
let service = HelloService ;
let server = bind.serve;
server.await
}
A TypeScript client using the generated code would look like that:
import { Client } from 'api/v1' // this is the generated code
client = new Client('http://localhost:8000/')
const response = await client.hello({ name: 'World' })
assert(response.message === 'Hello World!')
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.