GithubHelp home page GithubHelp logo

charconstpointer / waggy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from syke99/waggy

0.0 0.0 0.0 188 KB

The dead simple, easy-to-use library for writing HTTP handlers and routers in Go that can be used in standard HTTP server environments or in WAGI (Web Assembly Gateway Interface) environments

License: BSD 3-Clause "New" or "Revised" License

Go 100.00%

waggy's Introduction

Waggy

Go Reference Go Reportcard Codecov LICENSE

The dead simple, easy-to-use library for writing HTTP handlers and routers in Go that can be used in standard HTTP server environments or in WAGI (Web Assembly Gateway Interface) environments

What problems do Waggy solve?

With WAGI (Web Assembly Gateway Interface), HTTP requests are routed to specific handlers as defined in a modules.toml file (more information can be found here) to specific functions in a WASM module or WAT file. It accomplishes this by passing in the HTTP request information via os.Stdin and os.Args, and returning HTTP responses via os.Stdout. To remove considerable amounts of boilerplate code and to provide a familiar API for handling these WAGI HTTP requests, Waggy was created. It provides path parameter access functionality that will feel very reminiscent to those who have used gorilla/mux. Additionally, you can also map multiple handlers to a specific route based on the specific HTTP method that was used in the incoming request. Waggy also allows users to compile an entire server's worth of routes into a single WASM module and bypass setting up their routes via a modules.toml file if they so choose by handling mapping the route to the correct entry point (handler). But don't worry, you can also compile individual routes into their own WASM modules, too, so you can use the conventional modules.toml file for routing.


v0.5.0 improvements:

  • Restricting Methods: With v0.5.0, you have the ability to restrict HTTP methods on your handlers to make sure your endpoints are more secure

  • No Matched Routes: Another added feature in v0.5.0 is handling cases where no routes are matches to the route of the incoming request with generic 405 responses, as well as the ability to set custom handlers for the same edge case

How do I use Waggy?

Installing

To install Waggy in a repo, simply run

$ go get github.com/syke99/waggy

Then you can import the package in any go file you'd like

import "github.com/syke99/waggy"

Basic usage

Examples of using both Routers and Handlers for compiling WASM modules for WAGI can be found in the examples repo.

!!NOTE!!

To learn more about configuring, routing, compiling, and deploying WAGI routes, as well as the limitations of WAGI routes, please consult the WAGI docs and the TinyGo WASM docs

Who?

This library was developed by Quinn Millican (@syke99)

License

This repo is under the BSD 3 license, see LICENSE for details.

waggy's People

Contributors

syke99 avatar charconstpointer 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.