Giter VIP home page Giter VIP logo

rust-tide's Introduction

Rust Tide Stack

This has now been merged into the main appsody repository

https://github.com/appsody/stacks/tree/master/experimental/rust-tide

The Rust Tide stack provides a consistent way of developing tide http servers.

Designed to be used with Appsody an open source development and operations accelerator for containers.

This stack is based on the Rust 1.42 runtime.

Templates

Templates are used to create your local project and start your development. When initializing your project you will be provided with the default template project. This template provides a http server that returns "Hello World" on http://localhost:8000/hello.

Getting Started

  1. Clone this repo and configure appsody

    git clone https://github.com/No9/rust-tide
    cd rust-tide
    appsody stack package
  2. Create a new folder in your local directory and initialize it using the Appsody CLI, e.g.:

    mkdir my-project
    cd my-project
    appsody init dev.local/rust-tide

    This will initialize a Tide project using the default template.

  3. After your project has been initialized you can then run your application using the following command:

    appsody run

    This launches a Docker container that continuously re-builds and re-runs your project. It also exposes port 8000 to allow you to call your service from your browser and test tooling.

  4. You should see a message printed on the console:

    Running `server/bin/target/debug/rust-tide-server

  5. Open a browser at http://localhost:8000/hello

    It should return Hello, world.

  6. Now open lib.rs and change world to tide and save the file.

    pub fn app() -> tide::server::Server<()> {    
        let mut api = tide::new();
        api.at("/hello").get(|_| async move { "Hello, Tide" });
        api
    }
  7. Your application will be rebuild and republished so refresh http://localhost:8000/hello it will now say Hello, Tide

Debugging

To debug your application running in a container, start the container using:

    appsody debug --docker-options "--cap-add=SYS_PTRACE --security-opt seccomp=unconfined"

The command will start the LLDB platform and wait for incoming connections from any address to port 1234.

You can connect lldb in remote debug mode to this container as follows:

lldb \
  -o "platform select remote-linux" \
  -o "platform connect connect://localhost:1234" \
  -o "platform settings -w /project/server/bin/target/debug" \
  -o "file rust-tide-server" 

Once in lldb, you can use breakpoint set to set breakpoints in your application, and then run to start the app.

NOTE: Due to a current limitation, breakpoints must be set before the application is run. Breakpoints can be disabled, but cannot be re-enabled without restarting the app. After adding or re-enabling breakpoints, restart the app with process kill and then run.

License

This stack is licensed under the Apache 2.0 license

rust-tide's People

Contributors

no9 avatar

Stargazers

Shubham Chitranshi avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.