Coder Social home page Coder Social logo

spin-url-shortener's Introduction

A simple URL shortener built with Spin

This is a simple URL shortener built with Spin, running as a WebAssembly module.

The only configuration needed is the source and destination to redirect to:

[[route]]
source = "/spin"
destination = "https://github.com/fermyon/spin"

[[route]]
source = "/hype"
destination = "https://www.fermyon.com/blog/how-to-think-about-wasm"

Running can be done from the root of the repository with Spin:

$ spin up --file spin.toml

Then, sending requests to routes configured in routes.toml returns the response pointing to the configured destination:

$ curl -i localhost:3000/spin
HTTP/1.1 308 Permanent Redirect
location: https://github.com/fermyon/spin
content-length: 0
date: Tue, 22 Mar 2022 03:02:00 GMT

$ curl -i localhost:3000/hype
HTTP/1.1 308 Permanent Redirect
location: https://www.fermyon.com/blog/how-to-think-about-wasm
content-length: 0

spin-url-shortener's People

Contributors

on0n0k1 avatar radu-matei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spin-url-shortener's Issues

Error processing Request

I did a simple clone of the project. Ran:

spin build

Then:

spin up

The server starts, when I connect to the ip:port, it receives the request. But has issues parsing it.

Following is the request made from the terminal:

$ curl -i localhost:3000/spin
HTTP/1.1 500 Internal Server Error
content-length: 0
date: Fri, 23 Sep 2022 19:42:53 GMT

Following is the logs from the runtime:

$ spin up
Serving http://127.0.0.1:3000
Available Routes:
  shortener: http://127.0.0.1:3000 (wildcard)
2022-09-23T19:42:53.174517Z ERROR spin_http_engine: Error processing request: invalid discriminant for `option`    

The error message is the same. Regardless of connecting to localhost:3000/spin, localhost:3000/hype, localhost:3000/abc, etc.

The crate hasn't changed in the last few months. So I think it may be some change from the latest release.

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.