Code Monkey home page Code Monkey logo

belajar_web_service_rust's Introduction

Belajar Web Server With Rush x Inarust

thanks to inarust for the boilerplate ๐Ÿคฉ

How To Use

  1. Copy .env.example to .env

    mv .env.example .env
  2. Set your database connection and your server host to serve this web on your new .env file

    nano .env
    
    DB_URL=<MONGO DB CONNECTION STRING>
    DB_NAME=<DATABASE NAME>
    HOST=<HOST>:<PORT>
    

    example value

    DB_URL=mongodb://localhost:27017
    DB_NAME=mydatabase
    HOST=0.0.0.0:8080
  3. Run your web server with cargo on your terminal

    cargo run
    
  4. Test your web server

    1. test using curl from your terminal

      test hit base url

      curl --request GET \
      --url http://localhost:8080/
      

      test hit add user

      curl --request POST \
      --url http://localhost:8080/user \
      --header 'Content-Type: application/json' \
      --data '{
      "username": "Coba Lag",
      "email": "[email protected]"
      }'
      

      test hit get all user

      curl --request GET \
      --url http://localhost:8080/users
      

      test hit get detail user

      curl --request GET \
      --url http://localhost:8080/user/fbcbac32-c05b-4f63-82fd-cc82ab53e103
      

      test hit update user

      curl --request PUT \
      --url http://localhost:8080/user/fbcbac32-c05b-4f63-82fd-cc82ab53e103 \
      --header 'Content-Type: application/json' \
      --data '{
      "username": "Inara 2",
      "email": "[email protected]"
      }'
      

      test hit delete user

      curl --request DELETE \
      --url http://localhost:8080/user/bab2d00f-27bc-425f-9f45-1f1873884329
      
      
    2. test using api client, im using bruno Lihat pada folder doc

  5. Build for deployment, you can build your rust app with cargo using this command in your terminal

    cargo build
    

Have A Nice Day ๐Ÿ‘‹

belajar_web_service_rust's People

Contributors

mahaulia avatar

Watchers

 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.