Skip to content
This repository has been archived by the owner on Oct 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #50 from obsidian-rs/develop
Browse files Browse the repository at this point in the history
Version 0.2.0
  • Loading branch information
jk-gan committed Apr 22, 2020
2 parents b3b806b + 8b192a3 commit c264450
Show file tree
Hide file tree
Showing 25 changed files with 1,534 additions and 939 deletions.
Binary file added .github/media/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 30 additions & 22 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ name: Obsidian Action
on:
push:
branches:
- master
- develop
- release/*
- master
- develop
- release/*
pull_request:
branches:
- master
- develop
- master
- develop

jobs:
build_stable:
Expand All @@ -21,15 +21,19 @@ jobs:
rust: [stable]

steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- uses: actions/checkout@v1
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- uses: actions/checkout@v1
- name: Build
run: cargo build --verbose
- name: Install clippy
run: rustup component add clippy
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run tests
run: cargo test --verbose

build_nightly:
name: Nightly
runs-on: ${{ matrix.os }}
Expand All @@ -39,11 +43,15 @@ jobs:
rust: [nightly]

steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- uses: actions/checkout@v1
- name: Build
run: cargo +nightly build --verbose
- name: Run tests
run: cargo +nightly test --verbose
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- uses: actions/checkout@v1
- name: Build
run: cargo +nightly build --verbose
# - name: Install clippy
# run: rustup component add clippy
# - name: Run clippy
# run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run tests
run: cargo +nightly test --verbose
62 changes: 43 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
[[example]]
name = 'example'
path = 'examples/main.rs'

[[example]]
name = 'hello'
path = 'examples/hello.rs'

[[example]]
name = 'hello_handler'
path = 'examples/hello_handler.rs'

[[example]]
name = 'json'
path = 'examples/json.rs'

[[example]]
name = 'app_state'
path = 'examples/app_state.rs'

[package]
name = "obsidian"
version = "0.1.0-alpha.1"
authors = ["Gan Jun Kai <[email protected]>", "Wai Pai Lee <[email protected]>"]
edition = "2018"
description = "A Rust framework"
repository = "https://github.com/obsidian-rs/obsidian"
license = "MIT"
name = 'obsidian'
version = '0.2.0-alpha.1'
authors = [
'Gan Jun Kai <[email protected]>',
'Wai Pai Lee <[email protected]>',
]
edition = '2018'
description = 'A Rust framework'
repository = 'https://github.com/obsidian-rs/obsidian'
license = 'MIT'

[dependencies]
hyper = "0.12.15"
futures = "0.1"
http = "0.1.14"
serde_json = "1.0.33"
serde_derive = "1.0.80"
serde = "1.0.99"
tokio-fs = "0.1.4"
tokio-io = "0.1.10"
url = "1.7.2"
hyper = '0.13.1'
http = '0.2.0'
serde_json = '1.0.44'
url = '2.1.0'
async-std = '1.4.0'
async-trait = '0.1.22'

[[example]]
name = "example"
path = "example/main.rs"
[dependencies.serde]
version = '1.0.104'
features = ['derive']

[dependencies.tokio]
version = '0.2.6'
features = ['macros']
103 changes: 73 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,94 @@
# Obsidian

## What's Obsidian?

`Obsidian` is a web-application framework in Rust with a vision to make Rust web development fun.

## Code Status

| **Version** | **Master** |
| :--------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------: |
| [![](http://meritbadge.herokuapp.com/obsidian)](https://crates.io/crates/obsidian) | [![Actions Status](https://github.com/obsidian-rs/obsidian/workflows/Obsidian%20Action/badge.svg)](https://github.com/obsidian-rs/obsidian/actions) |
<p align="center">
<a href="https://obsidian-rs.github.io">
<img alt="Obsidian Logo" src=".github/media/logo.png" width="450">
</a>
<h1 align="center">
Obsidian
</h1>
</p>
<div align="center">
<a href="https://crates.io/crates/obsidian">
<img alt="Obsidian crate" src="https://img.shields.io/crates/v/obsidian.svg">
</a>
<a href="https://github.com/obsidian-rs/obsidian/actions">
<img alt="GitHub Actions status" src="https://github.com/obsidian-rs/obsidian/workflows/Obsidian%20Action/badge.svg">
</a>
</div>

<p align="center"><strong>Obsidian</strong> is a Rust web framework with a vision to make Rust web development fun.</p>

## Hello World
```rust
use obsidian::App;

fn main() {
let mut app = App::new();
let addr = ([127, 0, 0, 1], 3000).into();
#[tokio::main]
async fn main() {
let mut app = App::new();
let addr = ([127, 0, 0, 1], 3000).into();

app.get("/", |_ctx| {
"Hello World"
});
app.get("/", |ctx: Context| async { ctx.build("Hello World").ok() });

app.listen(&addr, || {
println!("server is listening to {}", &addr);
});
app.listen(&addr, || {
{
println!("server is listening to {}", &addr);
}
}).await;
}
```

## Hello World (with handler function)
```rust
use obsidian::{App, router::Responder, context::Context};
use obsidian::{context::Context, App, ContextResult};

async fn hello_world(ctx: Context) -> ContextResult {
ctx.build("Hello World").ok()
}


fn hello_world(_ctx: Context) -> impl Responder {
"Hello World"
#[tokio::main]
async fn main() {
let mut app = App::new();
let addr = ([127, 0, 0, 1], 3000).into();

app.get("/", hello_world);

app.listen(&addr, || {
println!("server is listening to {}", &addr);
})
.await;
}
```

fn main() {
let mut app = App::new();
let addr = ([127, 0, 0, 1], 3000).into();
## JSON Response
```rust
use obsidian::{context::Context, App, ContextResult};
use serde::*;

async fn get_user(ctx: Context) -> ContextResult {
#[derive(Serialize, Deserialize)]
struct User {
name: String,
};

let user = User {
name: String::from("Obsidian"),
};
ctx.build_json(user).ok()
}

#[tokio::main]
async fn main() {
let mut app: App = App::new();
let addr = ([127, 0, 0, 1], 3000).into();

app.get("/", hello_world);
app.get("/user", get_user);

app.listen(&addr, || {
println!("server is listening to {}", &addr);
});
app.listen(&addr, || {
println!("server is listening to {}", &addr);
})
.await;
}

```

## Example Files
Expand Down
Loading

0 comments on commit c264450

Please sign in to comment.