All Projects → xyproto → mooseware

xyproto / mooseware

Licence: MIT License
💀 Skeleton for writing a middleware handler

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to mooseware

go-wasm-examples
Some small examples of using Go and WebAssembly
Stars: ✭ 22 (-53.19%)
Mutual labels:  example
document-server-integration
Examples on how to integrate ONLYOFFICE Document Server into your own website or application
Stars: ✭ 68 (+44.68%)
Mutual labels:  example
Agora-C Sharp-SDK
The simple ways to use Agora RTC SDK with C#
Stars: ✭ 18 (-61.7%)
Mutual labels:  example
express-xml-bodyparser
Simple XML body parser connect/express middleware
Stars: ✭ 64 (+36.17%)
Mutual labels:  middleware
haskell-tic-tac-toe
A multiplayer web real-time implementation of the famous Tic Tac Toe game in Haskell.
Stars: ✭ 51 (+8.51%)
Mutual labels:  example
node-opencv-templatematching-test
Test for template matching using node-opencv
Stars: ✭ 20 (-57.45%)
Mutual labels:  example
whoops-middleware
PSR-15 compatible middleware for Whoops, the pretty error handler
Stars: ✭ 24 (-48.94%)
Mutual labels:  middleware
EnttPong
Built for EnTT, at the request of the developer as a demo.
Stars: ✭ 51 (+8.51%)
Mutual labels:  example
vue-vuex-todomvc
Example TodoMVC Vue.js app with Vuex store and server backend via REST
Stars: ✭ 41 (-12.77%)
Mutual labels:  example
mocking-with-jest
API Testing with Jest
Stars: ✭ 41 (-12.77%)
Mutual labels:  example
Examples Gtkmm
Shows how to use Gtkmm controls by programming code (c++17).
Stars: ✭ 23 (-51.06%)
Mutual labels:  example
python-in-browser
🐍🛥🌟 Running Python in the browser with Batavia and Starlette
Stars: ✭ 12 (-74.47%)
Mutual labels:  example
jwt-auth
JSON Web Token Authentication for Laravel and Lumen
Stars: ✭ 46 (-2.13%)
Mutual labels:  middleware
express-ping
Let all your express applications expose a common API to inform about their internal status and health.
Stars: ✭ 50 (+6.38%)
Mutual labels:  middleware
ddd-example-ecommerce
Domain-driven design example in Java with Spring framework
Stars: ✭ 73 (+55.32%)
Mutual labels:  example
laravel-docker-redis
Simple example: How to use laravel and redis using docker compose
Stars: ✭ 23 (-51.06%)
Mutual labels:  example
lagom-samples
developer.lightbend.com/start/?group=lagom
Stars: ✭ 85 (+80.85%)
Mutual labels:  example
discord-giveaways-bot
🎁Giveways Bot using the discord-giveaways package
Stars: ✭ 118 (+151.06%)
Mutual labels:  example
Object-Detection-Using-YOLO-v2-Deep-Learning
MATLAB example of deep learning based object detection using Yolo v2 with ResNet50 Base Network
Stars: ✭ 34 (-27.66%)
Mutual labels:  example
interface-doc
The technical specification of the data interface that describes how to integrate the fiskaltrust Middleware into POS systems.
Stars: ✭ 17 (-63.83%)
Mutual labels:  middleware

Mooseware

Build Status

Simple example/skeleton code for writing a middleware handler.

Middleware example

package moose

import (
	"log"
	"net/http"
)

type Middleware struct {
	moose bool
}

// Middleware is a struct that has a ServeHTTP method
func NewMiddleware() *Middleware {
	return &Middleware{true}
}

// The middleware handler
func (l *Middleware) ServeHTTP(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {
	// Log moose status
	log.Printf("MOOSE: %v\n", l.moose)

	// Call the next middleware handler
	next(w, req)
}

Usage

package main

import (
	"fmt"
	"net/http"

	"github.com/urfave/negroni"
	"github.com/xyproto/mooseware"
)

func main() {
	mux := http.NewServeMux()

	mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
		fmt.Fprint(w, "Bafflesnark!")
	})

	n := negroni.Classic()

	// Moose status
	n.Use(moose.NewMiddleware())

	// Handler goes last
	n.UseHandler(mux)

	// Serve
	n.Run(":3000")
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].