├── todo
├── migrations
│ ├── .gitkeep
│ ├── 2018-07-05-163612_create_tasks_table
│ │ ├── down.sql
│ │ └── up.sql
│ └── 00000000000000_diesel_initial_setup
│ │ ├── down.sql
│ │ └── up.sql
├── .env
├── src
│ ├── schema.rs
│ ├── session.rs
│ ├── model.rs
│ ├── db.rs
│ └── main.rs
├── diesel.toml
├── Cargo.toml
├── static
│ ├── errors
│ │ ├── 400.html
│ │ ├── 404.html
│ │ └── 500.html
│ └── css
│ │ └── style.css
├── README.md
└── templates
│ └── index.html.tera
├── diesel
├── .gitignore
├── .env
├── migrations
│ └── 20170124012402_create_users
│ │ ├── down.sql
│ │ └── up.sql
├── src
│ ├── schema.rs
│ ├── models.rs
│ ├── actions.rs
│ └── main.rs
├── Cargo.toml
└── README.md
├── rustfmt.toml
├── simple-auth-server
├── migrations
│ ├── .gitkeep
│ ├── 2018-10-09-101948_users
│ │ ├── down.sql
│ │ └── up.sql
│ ├── 2018-10-16-095633_invitations
│ │ ├── down.sql
│ │ └── up.sql
│ └── 00000000000000_diesel_initial_setup
│ │ ├── down.sql
│ │ └── up.sql
├── diesel.toml
├── src
│ ├── schema.rs
│ ├── utils.rs
│ ├── models.rs
│ ├── invitation_handler.rs
│ ├── errors.rs
│ ├── main.rs
│ ├── email_service.rs
│ ├── register_handler.rs
│ └── auth_handler.rs
├── static
│ ├── main.css
│ ├── main.js
│ ├── index.html
│ └── register.html
├── Cargo.toml
└── README.md
├── static_index
├── README.md
├── .gitattributes
├── static
│ ├── actixLogo.png
│ ├── favicon.ico
│ └── index.html
├── Cargo.toml
└── src
│ └── main.rs
├── error_handling
├── .gitignore
├── README.md
└── Cargo.toml
├── async_pg
├── .gitignore
├── sql
│ ├── get_users.sql
│ ├── add_user.sql
│ └── schema.sql
├── Cargo.toml
└── README.md
├── multipart
├── .gitignore
├── README.md
├── Cargo.toml
├── LICENSE
└── src
│ └── main.rs
├── template_yarte
├── templates
│ ├── deep
│ │ └── more
│ │ │ ├── doc
│ │ │ ├── t.hbs
│ │ │ └── head.hbs
│ │ │ ├── card
│ │ │ ├── hi.hbs
│ │ │ └── form.hbs
│ │ │ └── deep
│ │ │ └── welcome.hbs
│ ├── base.hbs
│ └── index.hbs
├── build.rs
├── yarte.toml
├── Cargo.toml
└── README.md
├── async_ex2
├── src
│ ├── handlers
│ │ ├── mod.rs
│ │ ├── parts.rs
│ │ └── products.rs
│ ├── lib.rs
│ ├── common.rs
│ ├── bin
│ │ └── main.rs
│ └── appconfig.rs
├── README.md
└── Cargo.toml
├── graphql-demo
├── .env.example
├── src
│ ├── schemas
│ │ ├── mod.rs
│ │ ├── product.rs
│ │ └── user.rs
│ ├── db.rs
│ ├── main.rs
│ └── handlers.rs
├── Cargo.toml
├── README.md
└── mysql-schema.sql
├── README.md
├── basics
├── static
│ ├── favicon.ico
│ ├── ntexLogo.png
│ ├── 404.html
│ └── welcome.html
├── Cargo.toml
└── README.md
├── tokio
├── static
│ ├── favicon.ico
│ ├── ntexLogo.png
│ ├── 404.html
│ └── welcome.html
├── Cargo.toml
└── README.md
├── websocket
├── static
│ ├── favicon.ico
│ ├── actixLogo.png
│ └── index.html
├── Cargo.toml
├── README.md
├── websocket-client.py
└── src
│ └── client.rs
├── async_db
├── db
│ ├── GHCND_documentation.pdf
│ ├── setup_db.sh
│ ├── README.md
│ └── db.sql
├── Cargo.toml
├── README.md
└── src
│ └── main.rs
├── websocket-lowlevel
├── static
│ ├── favicon.ico
│ └── index.html
├── Cargo.toml
├── README.md
└── src
│ └── client.rs
├── form
├── README.md
├── Cargo.toml
└── static
│ └── form.html
├── cookie-session
├── README.md
├── Cargo.toml
└── src
│ └── main.rs
├── state
├── README.md
├── Cargo.toml
└── src
│ └── main.rs
├── template_askama
├── templates
│ ├── user.html
│ └── index.html
├── Cargo.toml
└── src
│ └── main.rs
├── template_tera
├── templates
│ ├── user.html
│ └── index.html
├── Cargo.toml
├── README.md
└── src
│ └── main.rs
├── awc_https
├── Cargo.toml
├── README.md
└── src
│ └── main.rs
├── template_handlebars
├── static
│ └── templates
│ │ ├── user.html
│ │ └── index.html
├── Cargo.toml
└── src
│ ├── README.md
│ └── main.rs
├── hello-world
├── Cargo.toml
└── src
│ └── main.rs
├── unix-socket
├── Cargo.toml
├── README.md
└── src
│ └── main.rs
├── cookie-auth
├── Cargo.toml
├── README.md
└── src
│ └── main.rs
├── openssl
├── Cargo.toml
├── README.md
├── cert.pem
├── src
│ └── main.rs
└── key.pem
├── run-in-thread
├── Cargo.toml
└── src
│ └── main.rs
├── http-proxy
├── README.md
└── Cargo.toml
├── server-sent-events
├── Cargo.toml
├── src
│ └── index.html
├── drain.js
├── README.md
└── benchmark.js
├── json_error
├── Cargo.toml
└── src
│ └── main.rs
├── juniper
├── Cargo.toml
├── README.md
└── src
│ ├── main.rs
│ └── schema.rs
├── shutdown-server
├── Cargo.toml
├── README.md
└── src
│ └── main.rs
├── docker_sample
├── Cargo.toml
├── Dockerfile
├── README.MD
└── src
│ └── main.rs
├── middleware
├── Cargo.toml
├── README.md
└── src
│ ├── main.rs
│ ├── simple.rs
│ ├── read_request_body.rs
│ ├── redirect.rs
│ └── read_response_body.rs
├── json
├── Cargo.toml
├── client.py
└── README.md
├── jsonrpc
├── Cargo.toml
├── README.md
└── tests
│ └── test_client.py
├── rustls
├── README.md
├── Cargo.toml
├── src
│ └── main.rs
└── cert.pem
├── r2d2
├── Cargo.toml
└── src
│ └── main.rs
├── async_ex1
├── Cargo.toml
└── README.md
├── websocket-chat
├── Cargo.toml
├── README.md
├── client.py
└── static
│ └── websocket.html
├── .gitignore
├── websocket-tcp-chat
├── Cargo.toml
├── src
│ ├── main.rs
│ └── client-ws.rs
├── README.md
├── client.py
└── static
│ └── websocket.html
├── Cargo.toml
└── .travis.yml
/todo/migrations/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/diesel/.gitignore:
--------------------------------------------------------------------------------
1 | test.db
2 |
--------------------------------------------------------------------------------
/rustfmt.toml:
--------------------------------------------------------------------------------
1 | max_width = 89
2 |
--------------------------------------------------------------------------------
/diesel/.env:
--------------------------------------------------------------------------------
1 | DATABASE_URL=test.db
2 |
--------------------------------------------------------------------------------
/simple-auth-server/migrations/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static_index/README.md:
--------------------------------------------------------------------------------
1 | # static_index
2 |
--------------------------------------------------------------------------------
/error_handling/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | **/*.rs.bk
3 |
--------------------------------------------------------------------------------
/async_pg/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | **/*.rs.bk
3 | .env
4 |
--------------------------------------------------------------------------------
/multipart/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | **/*.rs.bk
3 | /tmp
4 |
--------------------------------------------------------------------------------
/todo/.env:
--------------------------------------------------------------------------------
1 | DATABASE_URL=postgres://localhost/ntex_todo
2 |
--------------------------------------------------------------------------------
/template_yarte/templates/deep/more/doc/t.hbs:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/async_ex2/src/handlers/mod.rs:
--------------------------------------------------------------------------------
1 | pub mod parts;
2 | pub mod products;
3 |
--------------------------------------------------------------------------------
/async_pg/sql/get_users.sql:
--------------------------------------------------------------------------------
1 | SELECT $table_fields FROM testing.users;
2 |
--------------------------------------------------------------------------------
/diesel/migrations/20170124012402_create_users/down.sql:
--------------------------------------------------------------------------------
1 | DROP TABLE users
2 |
--------------------------------------------------------------------------------
/graphql-demo/.env.example:
--------------------------------------------------------------------------------
1 | DATABASE_URL=mysql://user:password@127.0.0.1/dbname
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ntex examples
2 |
3 | A curated list of examples related to ntex.
4 |
--------------------------------------------------------------------------------
/todo/migrations/2018-07-05-163612_create_tasks_table/down.sql:
--------------------------------------------------------------------------------
1 | DROP TABLE tasks
2 |
--------------------------------------------------------------------------------
/async_ex2/src/lib.rs:
--------------------------------------------------------------------------------
1 | pub mod appconfig;
2 | pub mod common;
3 | pub mod handlers;
4 |
--------------------------------------------------------------------------------
/graphql-demo/src/schemas/mod.rs:
--------------------------------------------------------------------------------
1 | pub mod product;
2 | pub mod root;
3 | pub mod user;
4 |
--------------------------------------------------------------------------------
/template_yarte/build.rs:
--------------------------------------------------------------------------------
1 | fn main() {
2 | yarte_helpers::recompile::when_changed();
3 | }
4 |
--------------------------------------------------------------------------------
/basics/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntex-rs/examples/HEAD/basics/static/favicon.ico
--------------------------------------------------------------------------------
/error_handling/README.md:
--------------------------------------------------------------------------------
1 | This project illustrates custom error propagation through futures in ntex
2 |
--------------------------------------------------------------------------------
/static_index/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/tokio/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntex-rs/examples/HEAD/tokio/static/favicon.ico
--------------------------------------------------------------------------------
/tokio/static/ntexLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntex-rs/examples/HEAD/tokio/static/ntexLogo.png
--------------------------------------------------------------------------------
/basics/static/ntexLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntex-rs/examples/HEAD/basics/static/ntexLogo.png
--------------------------------------------------------------------------------
/websocket/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntex-rs/examples/HEAD/websocket/static/favicon.ico
--------------------------------------------------------------------------------
/websocket/static/actixLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntex-rs/examples/HEAD/websocket/static/actixLogo.png
--------------------------------------------------------------------------------
/static_index/static/actixLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntex-rs/examples/HEAD/static_index/static/actixLogo.png
--------------------------------------------------------------------------------
/static_index/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntex-rs/examples/HEAD/static_index/static/favicon.ico
--------------------------------------------------------------------------------
/async_db/db/GHCND_documentation.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntex-rs/examples/HEAD/async_db/db/GHCND_documentation.pdf
--------------------------------------------------------------------------------
/diesel/src/schema.rs:
--------------------------------------------------------------------------------
1 | table! {
2 | users (id) {
3 | id -> Text,
4 | name -> Text,
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/websocket-lowlevel/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntex-rs/examples/HEAD/websocket-lowlevel/static/favicon.ico
--------------------------------------------------------------------------------
/form/README.md:
--------------------------------------------------------------------------------
1 | ## Form example
2 |
3 | ```bash
4 | cd form
5 | cargo run
6 | # Started http server: 127.0.0.1:8080
7 | ```
8 |
9 |
--------------------------------------------------------------------------------
/simple-auth-server/migrations/2018-10-09-101948_users/down.sql:
--------------------------------------------------------------------------------
1 | -- This file should undo anything in `up.sql`
2 | DROP TABLE users;
3 |
--------------------------------------------------------------------------------
/simple-auth-server/migrations/2018-10-16-095633_invitations/down.sql:
--------------------------------------------------------------------------------
1 | -- This file should undo anything in `up.sql`
2 | DROP TABLE invitations;
3 |
--------------------------------------------------------------------------------
/async_pg/sql/add_user.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO testing.users(email, first_name, last_name, username)
2 | VALUES ($1, $2, $3, $4)
3 | RETURNING $table_fields;
4 |
--------------------------------------------------------------------------------
/diesel/migrations/20170124012402_create_users/up.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE users (
2 | id VARCHAR NOT NULL PRIMARY KEY,
3 | name VARCHAR NOT NULL
4 | )
5 |
--------------------------------------------------------------------------------
/cookie-session/README.md:
--------------------------------------------------------------------------------
1 | ## Cookie session example
2 |
3 | ```sh
4 | cd cookie-session
5 | cargo run
6 | # Starting http server: 127.0.0.1:8080
7 | ```
8 |
--------------------------------------------------------------------------------
/todo/src/schema.rs:
--------------------------------------------------------------------------------
1 | table! {
2 | tasks (id) {
3 | id -> Int4,
4 | description -> Varchar,
5 | completed -> Bool,
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/async_ex2/README.md:
--------------------------------------------------------------------------------
1 | This example illustrates how to use nested resource registration through application-level configuration.
2 | The endpoints do nothing.
3 |
4 |
--------------------------------------------------------------------------------
/template_yarte/templates/base.hbs:
--------------------------------------------------------------------------------
1 | {{! Simple example !}}
2 | {{> doc/t }}
3 |
4 | {{> doc/head }}
5 |
6 | {{> @partial-block }}
7 |
8 |
9 |
--------------------------------------------------------------------------------
/todo/diesel.toml:
--------------------------------------------------------------------------------
1 | # For documentation on how to configure this file,
2 | # see diesel.rs/guides/configuring-diesel-cli
3 |
4 | [print_schema]
5 | file = "src/schema.rs"
6 |
--------------------------------------------------------------------------------
/async_db/db/setup_db.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | cd $(dirname "$0")
3 | sqlite3 ../weather.db < db.sql
4 | sqlite3 -csv ../weather.db ".import nyc_centralpark_weather.csv nyc_weather"
5 |
--------------------------------------------------------------------------------
/simple-auth-server/diesel.toml:
--------------------------------------------------------------------------------
1 | # For documentation on how to configure this file,
2 | # see diesel.rs/guides/configuring-diesel-cli
3 |
4 | [print_schema]
5 | file = "src/schema.rs"
6 |
--------------------------------------------------------------------------------
/todo/migrations/2018-07-05-163612_create_tasks_table/up.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE tasks (
2 | id SERIAL PRIMARY KEY,
3 | description VARCHAR NOT NULL,
4 | completed BOOLEAN NOT NULL DEFAULT 'f'
5 | );
6 |
--------------------------------------------------------------------------------
/template_yarte/templates/deep/more/card/hi.hbs:
--------------------------------------------------------------------------------
1 | {{!
2 | Hi message:
3 | args:
4 | - lastname
5 | - name
6 | !}}
7 | Hi, {{ name }} {{ lastname }}!
8 | {{~> alias/welcome id = "hi", tag = 'p', tail = "" }}
9 |
--------------------------------------------------------------------------------
/simple-auth-server/migrations/2018-10-16-095633_invitations/up.sql:
--------------------------------------------------------------------------------
1 | -- Your SQL goes here
2 | CREATE TABLE invitations (
3 | id UUID NOT NULL UNIQUE PRIMARY KEY,
4 | email VARCHAR(100) NOT NULL,
5 | expires_at TIMESTAMP NOT NULL
6 | );
7 |
--------------------------------------------------------------------------------
/template_yarte/templates/deep/more/doc/head.hbs:
--------------------------------------------------------------------------------
1 | {{# unless title.is_str() && !title.is_empty() }}
2 | {{$ "Need static args: title: str" }}
3 | {{/unless}}
4 |
5 |
6 | {{ title }}
7 |
8 |
--------------------------------------------------------------------------------
/simple-auth-server/migrations/2018-10-09-101948_users/up.sql:
--------------------------------------------------------------------------------
1 | -- Your SQL goes here
2 | CREATE TABLE users (
3 | email VARCHAR(100) NOT NULL UNIQUE PRIMARY KEY,
4 | hash VARCHAR(122) NOT NULL, --argon hash
5 | created_at TIMESTAMP NOT NULL
6 | );
7 |
--------------------------------------------------------------------------------
/async_db/db/README.md:
--------------------------------------------------------------------------------
1 | This directory includes weather information obtained from NOAA for NYC Central Park: https://www.ncdc.noaa.gov/cdo-web/
2 |
3 | # Setup Instructions
4 |
5 | Set up a sqlite3 database by executing the setup_db.sh file: `bash sqlite_db.sh`
6 |
--------------------------------------------------------------------------------
/state/README.md:
--------------------------------------------------------------------------------
1 | # state
2 |
3 | ## Usage
4 |
5 | ### server
6 |
7 | ```bash
8 | cd examples/state
9 | cargo run
10 | # Started http server: 127.0.0.1:8080
11 | ```
12 |
13 | ### web client
14 |
15 | - [http://localhost:8080/](http://localhost:8080/)
16 |
--------------------------------------------------------------------------------
/template_askama/templates/user.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ntex
6 |
7 |
8 | Hi, {{ name }}!
9 |
10 | {{ text }}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/template_tera/templates/user.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ntex
6 |
7 |
8 | Hi, {{ name }}!
9 |
10 | {{ text }}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/template_yarte/templates/index.hbs:
--------------------------------------------------------------------------------
1 | {{#> base title = "Ntex" }}
2 | {{~#if let Some(name) = query.get("name") }}
3 | {{ let lastname = query.get("lastname").ok_or(yarte::Error)? }}
4 | {{> card/hi ~}}
5 | {{ else ~}}
6 | {{> card/form ~}}
7 | {{/if ~}}
8 | {{/base }}
--------------------------------------------------------------------------------
/awc_https/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "awc_https"
3 | version = "3.0.0"
4 | authors = ["dowwie "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["openssl", "tokio"] }
9 | openssl = "0.10"
10 |
--------------------------------------------------------------------------------
/template_handlebars/static/templates/user.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{user}}'s homepage
6 |
7 |
8 |
9 | Welcome back, {{user}}
10 | Here's your {{data}}.
11 |
12 |
--------------------------------------------------------------------------------
/hello-world/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "hello-world"
3 | version = "4.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | env_logger = "0.11"
10 |
--------------------------------------------------------------------------------
/unix-socket/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "unix-socket"
3 | version = "3.0.0"
4 | authors = ["Messense Lv "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | env_logger = "0.11"
10 |
--------------------------------------------------------------------------------
/state/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "state"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | futures = "0.3"
10 | env_logger = "0.11"
11 |
--------------------------------------------------------------------------------
/form/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "form-example"
3 | version = "3.0.0"
4 | authors = ["Gorm Casper "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | serde = { version = "1.0", features = ["derive"] }
10 |
--------------------------------------------------------------------------------
/template_handlebars/static/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{name}} Example
6 |
7 |
8 |
9 | {{name}} example
10 | This is an example of how to use {{name}} with Ntex.
11 |
12 |
--------------------------------------------------------------------------------
/template_tera/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "template-tera"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | env_logger = "0.11"
9 | tera = "1.0"
10 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
11 |
--------------------------------------------------------------------------------
/cookie-auth/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "cookie-auth"
3 | version = "4.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | ntex-identity = "3.0.0"
10 | env_logger = "0.11"
11 |
--------------------------------------------------------------------------------
/template_yarte/yarte.toml:
--------------------------------------------------------------------------------
1 | # root dir of templates
2 | [main]
3 | dir = "templates"
4 |
5 | # Alias for partials. In call, change the start of partial path with one of this, if exist.
6 | [partials]
7 | alias = "./deep/more/deep"
8 | doc = "./deep/more/doc"
9 | card = "./deep/more/card"
10 |
--------------------------------------------------------------------------------
/openssl/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "openssl-example"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["openssl", "tokio"] }
9 | env_logger = "0.11"
10 | openssl = "0.10"
11 |
--------------------------------------------------------------------------------
/basics/static/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ntex - basics
6 |
7 |
8 |
9 |
10 | back to home
11 | 404
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/tokio/static/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ntex - basics
6 |
7 |
8 |
9 |
10 | back to home
11 | 404
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/run-in-thread/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "run-in-thread"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 | description = "Run ntex in separate thread"
7 |
8 | [dependencies]
9 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
10 | env_logger = "0.11"
11 |
--------------------------------------------------------------------------------
/tokio/static/welcome.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ntex - basics
6 |
7 |
8 |
9 |
10 | Welcome 
11 |
12 |
13 |
--------------------------------------------------------------------------------
/basics/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "basics"
3 | version = "4.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | ntex-files = "3"
10 | ntex-session = "3"
11 | futures = "0.3"
12 | env_logger = "0.11"
13 |
--------------------------------------------------------------------------------
/basics/static/welcome.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ntex - basics
6 |
7 |
8 |
9 |
10 | Welcome 
11 |
12 |
13 |
--------------------------------------------------------------------------------
/static_index/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "static_index"
3 | version = "3.0.0"
4 | authors = ["Jose Marinez "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | futures = "0.3"
9 | env_logger = "0.11"
10 |
11 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
12 | ntex-files = "3.0.0"
13 |
--------------------------------------------------------------------------------
/template_askama/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "template-askama"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | askama = "0.9"
10 |
11 | [build-dependencies]
12 | askama = "0.9"
13 |
--------------------------------------------------------------------------------
/http-proxy/README.md:
--------------------------------------------------------------------------------
1 | ## HTTP Full proxy example
2 |
3 | This is a relatively simple HTTP proxy, forwarding HTTP requests to another HTTP server, including
4 | request body, headers, and streaming uploads.
5 |
6 | To start:
7 |
8 | ``` shell
9 | cargo run
10 | ```
11 |
--------------------------------------------------------------------------------
/server-sent-events/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "server-sent-events"
3 | version = "3.0.0"
4 | authors = ["Arve Seljebu"]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | env_logger = "0.11"
10 | futures = "0.3"
11 | tokio = { version = "1", features = ["sync"] }
--------------------------------------------------------------------------------
/http-proxy/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "http-proxy"
3 | version = "4.0.0"
4 | authors = ["Nikolay Kim ", "Rotem Yaari "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | clap = "2.32"
10 | futures = "0.3"
11 | url = "2.1"
12 |
--------------------------------------------------------------------------------
/cookie-session/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "cookie-session"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | ntex-session = "3.0.0"
10 | futures = "0.3"
11 | time = "0.3"
12 | env_logger = "0.11"
13 |
--------------------------------------------------------------------------------
/json_error/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "json_error"
3 | version = "3.0.0"
4 | authors = ["Kai Yao "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | futures = "0.3"
10 | serde = { version = "1.0", features = ["derive"] }
11 | serde_json = "1.0"
12 |
--------------------------------------------------------------------------------
/multipart/README.md:
--------------------------------------------------------------------------------
1 | # Ntex Web File Upload with Async/Await
2 |
3 | ### Run
4 |
5 | ``` open web browser to localhost:3000 and upload file(s) ```
6 |
7 | ### Result
8 |
9 | ``` file(s) will show up in ./tmp in the same directory as the running process ```
10 |
11 | Note: this is a naive implementation and will panic on any error
12 |
--------------------------------------------------------------------------------
/juniper/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "juniper-example"
3 | version = "3.0.0"
4 | authors = ["pyros2097 "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | env_logger = "0.11"
10 | serde = "1.0"
11 | serde_json = "1.0"
12 | serde_derive = "1.0"
13 | juniper = "0.14"
14 |
--------------------------------------------------------------------------------
/shutdown-server/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "shutdown-server"
3 | version = "3.0.0"
4 | authors = ["Rob Ede "]
5 | edition = "2018"
6 | description = "Send a request to the server to shut it down"
7 |
8 | [dependencies]
9 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
10 | env_logger = "0.11"
11 | futures = "0.3"
12 |
--------------------------------------------------------------------------------
/async_pg/sql/schema.sql:
--------------------------------------------------------------------------------
1 | DROP SCHEMA IF EXISTS testing CASCADE;
2 | CREATE SCHEMA testing;
3 |
4 | CREATE TABLE testing.users (
5 | id BIGSERIAL PRIMARY KEY,
6 | email VARCHAR(200) NOT NULL,
7 | first_name VARCHAR(200) NOT NULL,
8 | last_name VARCHAR(200) NOT NULL,
9 | username VARCHAR(50) UNIQUE NOT NULL,
10 | UNIQUE (username)
11 | );
12 |
--------------------------------------------------------------------------------
/diesel/src/models.rs:
--------------------------------------------------------------------------------
1 | use serde::{Deserialize, Serialize};
2 |
3 | use crate::schema::users;
4 |
5 | #[derive(Debug, Clone, Serialize, Queryable, Insertable)]
6 | pub struct User {
7 | pub id: String,
8 | pub name: String,
9 | }
10 |
11 | #[derive(Debug, Clone, Serialize, Deserialize)]
12 | pub struct NewUser {
13 | pub name: String,
14 | }
15 |
--------------------------------------------------------------------------------
/docker_sample/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "docker_sample"
3 | version = "3.0.0"
4 | authors = ["docker_sample "]
5 | edition = "2018"
6 |
7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8 |
9 | [dependencies]
10 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
11 |
--------------------------------------------------------------------------------
/middleware/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "middleware-example"
3 | version = "3.0.0"
4 | authors = ["Gorm Casper ", "Sven-Hendrik Haase "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | env_logger = "0.11"
10 | futures = "0.3"
11 | pin-project = "1.0"
12 |
--------------------------------------------------------------------------------
/template_handlebars/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "template_handlebars"
3 | version = "3.0.0"
4 | authors = ["Alexandru Tiniuc "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | handlebars = { version = "3.0.0", features = ["dir_source"] }
10 | serde_json = "1.0"
11 |
--------------------------------------------------------------------------------
/error_handling/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "error_handling"
3 | version = "3.0.0"
4 | authors = ["dowwie "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | thiserror = "1"
10 | derive_more = "0.99"
11 | futures = "0.3"
12 | serde = "1"
13 | rand = "0.8"
14 | env_logger = "0.11"
15 |
--------------------------------------------------------------------------------
/async_ex2/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "async_ex2"
3 | version = "3.0.0"
4 | authors = ["dowwie "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | env_logger = "0.11"
10 | futures = "0.3"
11 | serde = { version = "^1.0", features = ["derive"] }
12 | serde_json = "1.0"
13 | time = "0.3"
14 |
--------------------------------------------------------------------------------
/docker_sample/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM rust:1 as builder
2 | WORKDIR /app
3 | ADD . /app
4 | RUN rustup target add x86_64-unknown-linux-musl
5 | RUN CARGO_HTTP_MULTIPLEXING=false cargo build --release --target x86_64-unknown-linux-musl
6 |
7 | FROM scratch
8 | COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/docker_sample /app
9 | EXPOSE 5000
10 | CMD ["/app"]
11 |
--------------------------------------------------------------------------------
/json/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "json-example"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | futures = "0.3"
10 | env_logger = "0.11"
11 | serde = { version = "1.0", features = ["derive"] }
12 | serde_json = "1.0"
13 | json = "0.12"
14 |
--------------------------------------------------------------------------------
/jsonrpc/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "jsonrpc-example"
3 | version = "3.0.0"
4 | authors = ["mohanson "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | env_logger = "0.11"
10 | futures = "0.3"
11 | log = "0.4"
12 | serde = { version = "1.0", features = ["derive"] }
13 | serde_json = "1.0"
14 |
--------------------------------------------------------------------------------
/template_yarte/templates/deep/more/deep/welcome.hbs:
--------------------------------------------------------------------------------
1 | {{!
2 | Welcome card:
3 | args:
4 | - tag
5 | - id
6 | - tail
7 | !}}
8 | {{#unless tag.is_match(r"^p|(h[1-6])$") && !id.is_empty() }}
9 | {{$ "Need static args: tag: str /^h[1-6]$/, id: str" }}
10 | {{/unless }}
11 | <{{ tag }} id="{{ id }}" class="welcome">Welcome{{ tail }}{{ tag }}>
12 |
--------------------------------------------------------------------------------
/template_tera/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ntex
6 |
7 |
8 | Welcome!
9 |
10 |
What is your name?
11 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/template_askama/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ntex
6 |
7 |
8 | Welcome!
9 |
10 |
What is your name?
11 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/tokio/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "tokio"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | ntex-files = "3"
10 | ntex-session = "3"
11 | ntex-rt = "3"
12 | futures = "0.3"
13 | env_logger = "0.11"
14 | tokio = { version = "1", features = ["full"] }
15 |
--------------------------------------------------------------------------------
/async_ex2/src/common.rs:
--------------------------------------------------------------------------------
1 | use serde::{Deserialize, Serialize};
2 |
3 | #[derive(Deserialize, Serialize)]
4 | pub struct Product {
5 | id: Option,
6 | product_type: Option,
7 | name: Option,
8 | }
9 |
10 | #[derive(Deserialize, Serialize)]
11 | pub struct Part {
12 | id: Option,
13 | part_type: Option,
14 | name: Option,
15 | }
16 |
--------------------------------------------------------------------------------
/openssl/README.md:
--------------------------------------------------------------------------------
1 | # tls example
2 |
3 | ## Usage
4 |
5 | ### server
6 |
7 | ```bash
8 | cd examples/openssl
9 | cargo run (or ``cargo watch -x run``)
10 | # Started http server: 127.0.0.1:8443
11 | ```
12 |
13 | ### web client
14 |
15 | - curl: ``curl -v https://127.0.0.1:8443/index.html --compressed -k``
16 | - browser: [https://127.0.0.1:8443/index.html](https://127.0.0.1:8443/index.html)
17 |
--------------------------------------------------------------------------------
/rustls/README.md:
--------------------------------------------------------------------------------
1 | # tls example
2 |
3 | ## Usage
4 |
5 | ### server
6 |
7 | ```bash
8 | cd examples/rustls
9 | cargo run (or ``cargo watch -x run``)
10 | # Started http server: 127.0.0.1:8443
11 | ```
12 |
13 | ### web client
14 |
15 | - curl: ``curl -v https://127.0.0.1:8443/index.html --compressed -k``
16 | - browser: [https://127.0.0.1:8443/index.html](https://127.0.0.1:8443/index.html)
17 |
--------------------------------------------------------------------------------
/todo/migrations/00000000000000_diesel_initial_setup/down.sql:
--------------------------------------------------------------------------------
1 | -- This file was automatically created by Diesel to setup helper functions
2 | -- and other internal bookkeeping. This file is safe to edit, any future
3 | -- changes will be added to existing projects as new migrations.
4 |
5 | DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass);
6 | DROP FUNCTION IF EXISTS diesel_set_updated_at();
7 |
--------------------------------------------------------------------------------
/r2d2/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "r2d2-example"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 |
10 | futures = "0.3"
11 | env_logger = "0.11"
12 | uuid = { version = "1", features = ["v4"] }
13 |
14 | r2d2 = "0.8"
15 | r2d2_sqlite = "0.14"
16 | rusqlite = "0.21"
17 |
--------------------------------------------------------------------------------
/async_ex1/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "awc_examples"
3 | version = "5.0.0"
4 | authors = ["dowwie "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | env_logger = "0.11"
10 | futures = "0.3"
11 | serde = { version = "1.0", features = ["derive"] }
12 | serde_json = "1.0"
13 | validator = "0.10"
14 | validator_derive = "0.10"
15 |
--------------------------------------------------------------------------------
/simple-auth-server/src/schema.rs:
--------------------------------------------------------------------------------
1 | table! {
2 | invitations (id) {
3 | id -> Uuid,
4 | email -> Varchar,
5 | expires_at -> Timestamp,
6 | }
7 | }
8 |
9 | table! {
10 | users (email) {
11 | email -> Varchar,
12 | hash -> Varchar,
13 | created_at -> Timestamp,
14 | }
15 | }
16 |
17 | allow_tables_to_appear_in_same_query!(invitations, users,);
18 |
--------------------------------------------------------------------------------
/rustls/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "rustls-example"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [[bin]]
8 | name = "rustls-server"
9 | path = "src/main.rs"
10 |
11 | [dependencies]
12 | env_logger = "0.11"
13 | rustls = "0.23"
14 | rustls-pemfile = "2"
15 | ntex = { version = "3.0.0-pre.6", features = ["rustls", "tokio"] }
16 | ntex-files = "3.0.0"
17 |
--------------------------------------------------------------------------------
/simple-auth-server/migrations/00000000000000_diesel_initial_setup/down.sql:
--------------------------------------------------------------------------------
1 | -- This file was automatically created by Diesel to setup helper functions
2 | -- and other internal bookkeeping. This file is safe to edit, any future
3 | -- changes will be added to existing projects as new migrations.
4 |
5 | DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass);
6 | DROP FUNCTION IF EXISTS diesel_set_updated_at();
7 |
--------------------------------------------------------------------------------
/template_tera/README.md:
--------------------------------------------------------------------------------
1 | # template_tera
2 |
3 | Minimal example of using the template [tera](https://github.com/Keats/tera) that displays a form.
4 |
5 | ## Usage
6 |
7 | ### server
8 |
9 | ```bash
10 | cd examples/template_tera
11 | cargo run (or ``cargo watch -x run``)
12 | # Started http server: 127.0.0.1:8080
13 | ```
14 |
15 | ### web client
16 |
17 | - [http://localhost:8080](http://localhost:8080)
18 |
--------------------------------------------------------------------------------
/template_handlebars/src/README.md:
--------------------------------------------------------------------------------
1 | # Handlebars
2 |
3 | This is an example of how to use Ntex with the [Handlebars templating language](https://crates.io/crates/handlebars), which is currently the most popular crate that achieves this. After starting the server with `cargo run`, you may visit the following pages:
4 |
5 | - http://localhost:8080
6 | - http://localhost:8080/Emma/documents
7 | - http://localhost:8080/Bob/passwords
8 |
--------------------------------------------------------------------------------
/awc_https/README.md:
--------------------------------------------------------------------------------
1 | The goal of this example is to show you how to use the ntex client (awc)
2 | for https related communication. As of ntex 2.0.0, one must be very
3 | careful about setting up https communication. **You could use the default
4 | awc api without configuring ssl but performance will be severely diminished**.
5 |
6 | This example downloads a 10MB image from wikipedia.
7 |
8 | To run:
9 | > curl http://localhost:3000 -o image.jpg
10 |
--------------------------------------------------------------------------------
/websocket/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "websocket"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [[bin]]
8 | name = "websocket-server"
9 | path = "src/main.rs"
10 |
11 | [[bin]]
12 | name = "websocket-client"
13 | path = "src/client.rs"
14 |
15 | [dependencies]
16 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
17 | ntex-files = "3"
18 | env_logger = "0.11"
19 | futures = "0.3"
20 |
--------------------------------------------------------------------------------
/websocket-chat/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "websocket-chat"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [[bin]]
8 | name = "websocket-chat-server"
9 | path = "src/main.rs"
10 |
11 | [dependencies]
12 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
13 | ntex-files = "3.0.0"
14 |
15 | rand = "0.8"
16 | futures = "0.3"
17 | env_logger = "0.11"
18 | serde = "1.0"
19 | serde_json = "1.0"
20 |
--------------------------------------------------------------------------------
/async_db/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "async_db"
3 | version = "5.0.0"
4 | authors = ["Darin Gordon "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | env_logger = "0.11"
10 | futures = "0.3"
11 | derive_more = "0.99"
12 | num_cpus = "1.13"
13 | r2d2 = "0.8"
14 | r2d2_sqlite = "0.14"
15 | rusqlite = "0.21"
16 | serde = { version = "1.0", features = ["derive"] }
17 | serde_json = "1.0"
18 |
--------------------------------------------------------------------------------
/docker_sample/README.MD:
--------------------------------------------------------------------------------
1 |
2 | Build image:
3 |
4 | ```shell
5 | docker build -t docker_sample --force-rm --no-cache -f Dockerfile .
6 | ```
7 |
8 | Run image:
9 |
10 | ```shell
11 |
12 | echo "== start sample_docker"
13 | docker run -d -p 5000:5000 docker_sample &
14 | docker ps
15 |
16 | echo "== wait 3s for startup"
17 | sleep 3s
18 |
19 | echo "== curl both routes"
20 | curl http://localhost:5000
21 | curl http://localhost:5000/again
22 |
23 | ```
--------------------------------------------------------------------------------
/multipart/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "multipart-example"
3 | version = "3.0.0"
4 | authors = ["Bevan Hunt "]
5 | edition = "2018"
6 | license = "MIT"
7 | description = "Simple file uploader in Ntex with Async/Await"
8 | keywords = ["ntex", "multipart"]
9 | repository = "https://github.com/ntex/examples"
10 | readme = "README.md"
11 |
12 | [dependencies]
13 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
14 | ntex-multipart = "3.0.0"
15 | futures = "0.3"
16 |
--------------------------------------------------------------------------------
/async_ex2/src/bin/main.rs:
--------------------------------------------------------------------------------
1 | use ntex::web::{self, middleware, App};
2 |
3 | use async_ex2::appconfig::config_app;
4 |
5 | #[ntex::main]
6 | async fn main() -> std::io::Result<()> {
7 | std::env::set_var("RUST_LOG", "ntex=info");
8 | env_logger::init();
9 |
10 | web::server(async || {
11 | App::new()
12 | .configure(config_app)
13 | .wrap(middleware::Logger::default())
14 | })
15 | .bind("127.0.0.1:8080")?
16 | .run()
17 | .await
18 | }
19 |
--------------------------------------------------------------------------------
/template_yarte/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "template_yarte"
3 | version = "1.0.0"
4 | authors = ["Juan Aguilar Santillana "]
5 | publish = false
6 | edition = "2018"
7 |
8 | workspace = ".."
9 |
10 | [dependencies]
11 | env_logger = "0.11"
12 | yarte = { version = "0.15", features = ["html-min"] }
13 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
14 |
15 | [build-dependencies.yarte_helpers]
16 | version = "0.8"
17 | default-features = false
18 | features = ["config"]
19 |
--------------------------------------------------------------------------------
/template_yarte/templates/deep/more/card/form.hbs:
--------------------------------------------------------------------------------
1 | {{!
2 | Form: What is your name?
3 | !}}
4 | {{> ../deep/welcome id = "welcome", tag = "h1", tail = '!' ~}}
5 |
6 |
What is your name?
7 |
16 |
17 |
--------------------------------------------------------------------------------
/async_pg/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "async_pg"
3 | version = "3.0.0"
4 | authors = ["dowwie "]
5 | edition = "2018"
6 | workspace = ".."
7 |
8 | [dependencies]
9 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
10 | config = "0.10"
11 | deadpool-postgres = { version = "0.10", features = ["serde"] }
12 | derive_more = "0.99"
13 | dotenv = "0.15"
14 | serde = { version = "1.0", features = ["derive"] }
15 | tokio-pg-mapper = "0.2"
16 | tokio-pg-mapper-derive = "0.2"
17 | tokio-postgres = "0.7"
18 |
--------------------------------------------------------------------------------
/graphql-demo/src/db.rs:
--------------------------------------------------------------------------------
1 | use r2d2_mysql::mysql::{Opts, OptsBuilder};
2 | use r2d2_mysql::MysqlConnectionManager;
3 |
4 | pub type Pool = r2d2::Pool;
5 |
6 | pub fn get_db_pool() -> Pool {
7 | let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
8 | let opts = Opts::from_url(&db_url).unwrap();
9 | let builder = OptsBuilder::from_opts(opts);
10 | let manager = MysqlConnectionManager::new(builder);
11 | r2d2::Pool::new(manager).expect("Failed to create DB Pool")
12 | }
13 |
--------------------------------------------------------------------------------
/async_db/db/db.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE nyc_weather(
2 | STATION TEXT,
3 | NAME TEXT,
4 | DATE TEXT,
5 | ACMH DOUBLE,
6 | AWND DOUBLE,
7 | FMTM DOUBLE,
8 | PGTM DOUBLE,
9 | PRCP DOUBLE,
10 | PSUN DOUBLE,
11 | SNOW DOUBLE,
12 | SNWD DOUBLE,
13 | TAVG DOUBLE,
14 | TMAX DOUBLE,
15 | TMIN DOUBLE,
16 | TSUN DOUBLE,
17 | WDF1 DOUBLE,
18 | WDF2 DOUBLE,
19 | WDF5 DOUBLE,
20 | WDFG DOUBLE,
21 | WDFM DOUBLE,
22 | WSF1 DOUBLE,
23 | WSF2 DOUBLE,
24 | WSF5 DOUBLE,
25 | WSFG DOUBLE,
26 | WSFM DOUBLE
27 | );
28 |
29 |
--------------------------------------------------------------------------------
/todo/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = ["Dan Munckton "]
3 | name = "todo"
4 | version = "3.0.0"
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
9 | ntex-files = "3"
10 | ntex-session = "3"
11 | dotenv = "0.15"
12 | env_logger = "0.11"
13 | futures = "0.3"
14 | log = "0.4"
15 | serde = { version = "1.0", features = ["derive"] }
16 | serde_json = "1.0"
17 | tera = "1.0"
18 |
19 | [dependencies.diesel]
20 | features = ["postgres", "r2d2"]
21 | version = "1.3.2"
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Generated by Cargo
2 | # will have compiled files and executables
3 | /*/target/
4 | target/
5 |
6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
8 | /*/Cargo.lock
9 | Cargo.lock
10 |
11 | # These are backup files generated by rustfmt
12 | **/*.rs.bk
13 |
14 | # intellij files
15 | .idea/**
16 |
17 | .history/
18 |
19 | # VS Code workspace config
20 | .vscode
21 |
22 | # For multipart example
23 | upload.png
24 |
--------------------------------------------------------------------------------
/unix-socket/README.md:
--------------------------------------------------------------------------------
1 | ## Unix domain socket example
2 |
3 | ```bash
4 | $ curl --unix-socket /tmp/ntex-uds.socket http://localhost/
5 | Hello world!
6 | ```
7 |
8 | Although this will only one thread for handling incoming connections
9 | according to the
10 | [documentation](https://docs.rs/ntex/latest/ntex/web/struct.HttpServer.html#method.bind_uds).
11 |
12 | And it does not delete the socket file (`/tmp/ntex-uds.socket`) when stopping
13 | the server so it will fail to start next time you run it unless you delete
14 | the socket file manually.
15 |
--------------------------------------------------------------------------------
/diesel/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "diesel-example"
3 | version = "3.0.0"
4 | authors = [
5 | "Nikolay Kim ",
6 | "Rob Ede ",
7 | ]
8 | edition = "2018"
9 |
10 | [dependencies]
11 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
12 | diesel = { version = "1.1", features = ["sqlite", "r2d2"] }
13 | dotenv = "0.15"
14 | env_logger = "0.11"
15 | futures = "0.3"
16 | r2d2 = "0.8"
17 | serde = { version = "1.0", features = ["derive"] }
18 | serde_json = "1.0"
19 | uuid = { version = "1", features = ["serde", "v4"] }
20 |
--------------------------------------------------------------------------------
/websocket-lowlevel/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "websocket-lowlevel"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [[bin]]
8 | name = "websocket-lowlevel-server"
9 | path = "src/main.rs"
10 |
11 | [[bin]]
12 | name = "websocket-lowlevel-client"
13 | path = "src/client.rs"
14 |
15 | [dependencies]
16 | ntex = { version = "3.0.0-pre.6", features = ["tokio", "openssl"] }
17 | ntex-files = "3.0.0"
18 | env_logger = "0.11"
19 | futures = "0.3"
20 |
21 | openssl = "0.10"
22 | ntex-tls = { version= "3.0.0", features = ["openssl"] }
--------------------------------------------------------------------------------
/json/client.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | # This script could be used for ntex multipart example test
4 | # just start server and run client.py
5 |
6 | import json
7 | import asyncio
8 | import aiohttp
9 |
10 | async def req():
11 | resp = await aiohttp.ClientSession().request(
12 | "post", 'http://localhost:8080/',
13 | data=json.dumps({"name": "Test user", "number": 100}),
14 | headers={"content-type": "application/json"})
15 | print(str(resp))
16 | print(await resp.text())
17 | assert 200 == resp.status
18 |
19 |
20 | asyncio.get_event_loop().run_until_complete(req())
21 |
--------------------------------------------------------------------------------
/static_index/src/main.rs:
--------------------------------------------------------------------------------
1 | use ntex::web::{self, middleware, App};
2 | use ntex_files as fs;
3 |
4 | #[ntex::main]
5 | async fn main() -> std::io::Result<()> {
6 | std::env::set_var("RUST_LOG", "info");
7 | env_logger::init();
8 |
9 | web::server(async || {
10 | App::new()
11 | // enable logger
12 | .wrap(middleware::Logger::default())
13 | .service(
14 | // static files
15 | fs::Files::new("/", "./static/").index_file("index.html"),
16 | )
17 | })
18 | .bind("127.0.0.1:8080")?
19 | .run()
20 | .await
21 | }
22 |
--------------------------------------------------------------------------------
/docker_sample/src/main.rs:
--------------------------------------------------------------------------------
1 | use ntex::web::{self, App, HttpResponse};
2 |
3 | #[web::get("/")]
4 | async fn index() -> HttpResponse {
5 | println!("GET: /");
6 | HttpResponse::Ok().body("Hello world!")
7 | }
8 |
9 | #[web::get("/again")]
10 | async fn again() -> HttpResponse {
11 | println!("GET: /again");
12 | HttpResponse::Ok().body("Hello world again!")
13 | }
14 |
15 | #[ntex::main]
16 | async fn main() -> std::io::Result<()> {
17 | println!("Starting ntex-web server");
18 |
19 | web::server(async || App::new().service((index, again)))
20 | .bind("0.0.0.0:5000")?
21 | .run()
22 | .await
23 | }
24 |
--------------------------------------------------------------------------------
/websocket/README.md:
--------------------------------------------------------------------------------
1 | # websocket
2 |
3 | Simple echo websocket server.
4 |
5 | ## Usage
6 |
7 | ### server
8 |
9 | ```bash
10 | cd examples/websocket
11 | cargo run --bin server
12 | # Started http server: 127.0.0.1:8080
13 | ```
14 |
15 | ### web client
16 |
17 | - [http://localhost:8080/index.html](http://localhost:8080/index.html)
18 |
19 | ### rust client
20 |
21 | ```bash
22 | cd examples/websocket
23 | cargo run --bin client
24 | ```
25 |
26 | ### python client
27 |
28 | - ``pip install aiohttp``
29 | - ``python websocket-client.py``
30 |
31 | if ubuntu :
32 |
33 | - ``pip3 install aiohttp``
34 | - ``python3 websocket-client.py``
35 |
--------------------------------------------------------------------------------
/graphql-demo/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "ntex-graphql-demo"
3 | version = "4.0.0"
4 | authors = ["Dwi Sulfahnur "]
5 | edition = "2018"
6 |
7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8 |
9 | [dependencies]
10 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
11 | futures = "0.3"
12 | juniper = "0.14"
13 | mysql = "17"
14 | r2d2 = "0.8"
15 | r2d2_mysql = "17.0"
16 | dotenv = "0.15"
17 | env_logger = "0.11"
18 | log = "0.4"
19 | serde = { version = "1.0", features = ["derive"] }
20 | serde_json = "1.0"
21 | uuid = { version = "0.8", features = ["serde", "v4"] }
22 |
--------------------------------------------------------------------------------
/websocket-lowlevel/README.md:
--------------------------------------------------------------------------------
1 | # websocket
2 |
3 | Simple echo websocket server.
4 |
5 | ## Usage
6 |
7 | ### server
8 |
9 | ```bash
10 | cd examples/websocket
11 | cargo run --bin server
12 | # Started http server: 127.0.0.1:8080
13 | ```
14 |
15 | ### web client
16 |
17 | - [http://localhost:8080/index.html](http://localhost:8080/index.html)
18 |
19 | ### rust client
20 |
21 | ```bash
22 | cd examples/websocket
23 | cargo run --bin client
24 | ```
25 |
26 | ### python client
27 |
28 | - ``pip install aiohttp``
29 | - ``python websocket-client.py``
30 |
31 | if ubuntu :
32 |
33 | - ``pip3 install aiohttp``
34 | - ``python3 websocket-client.py``
35 |
--------------------------------------------------------------------------------
/shutdown-server/README.md:
--------------------------------------------------------------------------------
1 | # shutdown-server
2 |
3 | Demonstrates how to shutdown the web server in a couple of ways:
4 |
5 | 1. remotely, via http request
6 |
7 | 2. sending a SIGINT signal to the server (control-c)
8 | - ntex server natively supports SIGINT
9 |
10 |
11 | ## Usage
12 |
13 | ### Running The Server
14 |
15 | ```bash
16 | cargo run --bin shutdown-server
17 |
18 | # Starting 8 workers
19 | # Starting "ntex-service-127.0.0.1:8080" service on 127.0.0.1:8080
20 | ```
21 |
22 | ### Available Routes
23 |
24 | - [GET /hello](http://localhost:8080/hello)
25 | - Regular hello world route
26 | - [POST /stop](http://localhost:8080/stop)
27 | - Calling this will shutdown the server and exit
28 |
--------------------------------------------------------------------------------
/simple-auth-server/static/main.css:
--------------------------------------------------------------------------------
1 | /* CSSTerm.com Easy CSS login form */
2 |
3 | .login {
4 | width:600px;
5 | margin:auto;
6 | border:1px #CCC solid;
7 | padding:0px 30px;
8 | background-color: #3b6caf;
9 | color:#FFF;
10 | }
11 |
12 | .field {
13 | background: #1e4f8a;
14 | border:1px #03306b solid;
15 | padding:10px;
16 | margin:5px 25px;
17 | width:215px;
18 | color:#FFF;
19 | }
20 |
21 | .login h1, p, .chbox, .btn {
22 | margin-left:25px;
23 | color:#fff;
24 | }
25 |
26 | .btn {
27 | background-color: #00CCFF;
28 | border:1px #03306b solid;
29 | padding:10px 30px;
30 | font-weight:bold;
31 | margin:25px 25px;
32 | cursor: pointer;
33 | }
34 |
35 | .forgot {
36 | color:#fff;
37 | }
38 |
--------------------------------------------------------------------------------
/simple-auth-server/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "simple-auth-server"
3 | version = "3.0.0"
4 | authors = ["mygnu "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | ntex-identity = "3"
9 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
10 | argonautica = "0.2"
11 | chrono = { version = "0.4.6", features = ["serde"] }
12 | derive_more = "0.99"
13 | diesel = { version = "1.4", features = ["postgres", "uuidv07", "r2d2", "chrono"] }
14 | dotenv = "0.15"
15 | env_logger = "0.11"
16 | futures = "0.3"
17 | r2d2 = "0.8"
18 | lazy_static = "1.3"
19 | serde = { version = "1.0", features = ["derive"] }
20 | serde_json = "1.0"
21 | sparkpost = "0.5"
22 | uuid = { version = "0.8", features = ["serde", "v4"] }
23 | time = "0.3"
--------------------------------------------------------------------------------
/websocket-tcp-chat/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "chat-example"
3 | version = "3.0.0"
4 | authors = ["Nikolay Kim "]
5 | edition = "2018"
6 |
7 | [[bin]]
8 | name = "websocket-tcp-chat-server"
9 | path = "src/main.rs"
10 |
11 | [[bin]]
12 | name = "websocket-tcp-chat-client"
13 | path = "src/client-ws.rs"
14 |
15 | [[bin]]
16 | name = "websocket-tcp-chat-tcp-client"
17 | path = "src/client-tcp.rs"
18 |
19 | [dependencies]
20 | ntex = { version = "3.0.0-pre.6", features = ["tokio"] }
21 | ntex-mqtt = "6.2.0"
22 | ntex-amqp = "5.1.0"
23 | ntex-files = "3.0.0"
24 |
25 | rand = "0.8"
26 | byteorder = "1.4"
27 | futures = "0.3"
28 | env_logger = "0.11"
29 | serde = { version = "1.0", features = ["derive"] }
30 | serde_json = "1.0"
31 |
--------------------------------------------------------------------------------
/async_ex2/src/handlers/parts.rs:
--------------------------------------------------------------------------------
1 | use ntex::web::{self, Error, HttpResponse};
2 |
3 | use crate::common::{Part, Product};
4 |
5 | pub async fn get_parts(
6 | _query: web::types::Query