Giter Club home page Giter Club logo

create-image's Introduction

Rust HTTP Function

Welcome to your new Rust function project! The boilerplate actix web server is in src/main.rs. It's configured to invoke the index function in src/handler.rs in response to both GET and POST requests. You should put your desired behavior inside that index function. In case you need to configure some resources for your function, you can do that in the configure function.

The app will expose three endpoints:

  • / Triggers the index function, for either GET or POST methods
  • /health/readiness The endpoint for a readiness health check
  • /health/liveness The endpoint for a liveness health check

You may use any of the available actix features to fulfill the requests at those endpoints.

Development

This is a fully self-contained application, so you can develop it as you would any other Rust application, e.g.

cargo build
cargo test
cargo run

Once running, the function is available at http://localhost:8080 and the health checks are at http://localhost:8080/health/readiness and http://localhost:8080/health/liveness. To POST data to the function, a utility such as curl may be used:

curl -d '{"hello": "world"}' \
  -H'content-type: application/json' \
  http://localhost:8080

Deployment

Use func to containerize your application, publish it to a registry and deploy it as a Knative Service in your Kubernetes cluster:

func deploy --registry=docker.io/<YOUR_ACCOUNT>

You can omit the --registry option by setting the FUNC_REGISTRY environment variable. And if you forget, you'll be prompted.

The output from a successful deploy should show the URL for the service, which you can also get via func info, e.g.

curl $(func info -o url)

Have fun!

create-image's People

Contributors

enchantednatures 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.