Skip to content

Commit 393c32e

Browse files
committed
Convert docs to mdbook project
1 parent 4e8f1e7 commit 393c32e

20 files changed

Lines changed: 552 additions & 146 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
book

README.md

Lines changed: 6 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,11 @@
1-
# webwire
2-
3-
![webwire logo](docs/logo.svg)
1+
![webwire logo](src/logo.svg)
42

53
[![Discord Chat](https://img.shields.io/discord/726922033039933472?label=Discord+Chat&color=%23677bc4&logo=discord&logoColor=white&style=for-the-badge)](https://discord.gg/jjD6aWG)
64

75
Webwire is a **contract-first API** system which features an
8-
[interface description language](docs/interface_description_language.md),
9-
a network [protocol](docs/protocol.md) and
10-
[code generator](docs/code_generator.md) for both servers and clients.
11-
12-
## Resources
13-
14-
- **Website:** https://webwire.dev/
15-
- **GitHub:** https://github.com/webwire/
16-
- **Discord:** https://discord.gg/jjD6aWG
17-
18-
## WORK IN PROGRESS
19-
20-
> **Webwire is not ready to use! All the documentation and code in this
21-
repository is either incomplete or non functional. Don't expect anything
22-
to work, yet. Right now this repository is just a collection of ideas and
23-
preliminary implementations.**
24-
25-
## Example
26-
27-
The following example assumes a Rust server and a TypeScript client. Webwire
28-
is by no means limited to those two but those languages show the potential of
29-
webwire best.
30-
31-
Given the following IDL file:
32-
33-
```webwire
34-
webwire 1.0;
35-
36-
struct HelloRequest {
37-
name: String,
38-
}
39-
40-
struct HelloResponse {
41-
message: String,
42-
}
43-
44-
service Hello {
45-
hello: HelloRequest -> HelloResponse
46-
}
47-
```
48-
49-
The server and client files can be generated using the code generator:
50-
51-
```bash
52-
$ webwire generate rust server api/hello.ww server/src/api.rs
53-
$ webwire generate ts client api/hello.ww client/src/api.ts
54-
```
55-
56-
A Rust server implementation for the given code would look like this:
57-
58-
```rust
59-
use std::net::SocketAddr;
60-
use webwire::{Context, Request, Response}
61-
use webwire::hyper::Server;
62-
63-
mod api;
64-
use api::v1::{Hello, HelloRequest, HelloResponse}; // this is the generated code
65-
66-
struct HelloService {}
67-
68-
impl Hello for HelloService {
69-
fn hello(&self, ctx: &Context, request: &HelloRequest) -> HelloResponse {
70-
HelloResponse {
71-
message: format!("Hello {}!", request.name)
72-
}
73-
}
74-
}
75-
76-
#[tokio::main]
77-
async fn main() -> Result<(), Box<dyn std::error::Error> {
78-
let addr = SocketAddr::from(([127, 0, 0, 1], 8000));
79-
let service = HelloService {};
80-
let server = webwire::Server::bind(addr).serve(service);
81-
server.await
82-
}
83-
```
84-
85-
A TypeScript client using the generated code would look like that:
86-
87-
```typescript
88-
import { Client } from 'api/v1' // this is the generated code
89-
90-
client = new Client('http://localhost:8000/')
91-
const response = await client.hello({ name: 'World' })
92-
assert(response.message === 'Hello World!')
93-
```
94-
95-
## Building blocks
96-
97-
- The [webwire interface description language](docs/interface_description_language.md)
98-
describes service endpoints and how they are called.
99-
100-
- The [webwire protocol](docs/protocol.md) is the actual representation
101-
how data is transferred between client and server.
102-
103-
- The [webwire code generator](docs/code_generator.md) uses the schema
104-
language to generate client and server stubs.
105-
106-
107-
## Unique selling points
108-
109-
- Webwire generates client and server code which is ready to run. The
110-
generated code contains everything to make requests and
111-
112-
- Webwire supports both **stateless unidirectional** communication and and
113-
**stateful bidirectional** communication. This makes it a perfect fit for
114-
application that require some kind of real-time update from the server
115-
without the client having to poll for updates.
116-
117-
- Webwire validates requests and responses. If data does not match the
118-
given schema an error is raised an the data is not processed any
119-
further.
120-
121-
- Webwire is modelled after programming languages and not after a
122-
serialization format. Therefore types like `UUID`, `Date` and `Time`
123-
are part of the specification even if the used serialization format
124-
does not support them. When using a serialization format which does
125-
not support those types natively (e.g. JSON) they are encoded as
126-
string. This is transparent to the users of webwire.
127-
128-
- Webwire has a special type called `fieldset`. Fieldsets can be used to
129-
construct a struct out of another struct by picking a subset of fields.
130-
This is especially useful when designing APIs where multiple endpoints
131-
use almost the same structure which just differs in a few fields.
132-
133-
134-
## Non goals
6+
[interface description language](/idl.md),
7+
a network [protocol](/protocol.md) and
8+
[code generator](/codegen.md) for both servers and clients.
1359

136-
- Webwire can not be used to describe existing APIs. Webwire only makes
137-
sense as a whole package. The IDL, protocol and code generator all make
138-
a complete package and leaving out one or the other just doesn't make
139-
any sense. If you need to document an existing API have a look at
140-
[OpenAPI](https://swagger.io/docs/specification/about/).
10+
This repository contains the documentation sources used to generate
11+
the website at [https://webwire.dev/](https://webwire.dev/).

book.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[book]
2+
authors = ["Michael P. Jung"]
3+
language = "en"
4+
multilingual = false
5+
src = "src"
6+
title = "Webwire"

docs/CNAME

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/_config.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/code_generator.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/logo-quadratic.png

-7.08 KB
Binary file not shown.

docs/protocol.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)