Giter VIP home page Giter VIP logo

aker's Introduction

Aker

Just a simple Golang middleware chaining package and router middleware package

p.s syntax and signatures are mostly inspired by koa2 from nodejs

Contex

type Contex struct {
	Response http.ResponseWriter // Sugar for ResponseWriter
	Request  *http.Request       // Sugar for Request
}

How to write a Aker Middleware

func Foo(ctx *aker.Contex, next func()) {
	//middleware logic
	next() //invoke next middleware, must be called or chain will stop here
}

Examples of router middle ware

func testAdd(ctx *aker.Contex) {
	//post logic
}

app := aker.Instance()
router := akerrouter.Instance()
router.Get("/api/testing", func(ctx aker.Context){
	//get logic
})
router.Post("/api/add", testAdd)
app.Use(router.Routes)

Examples of middleware chaining

Middleware A
Middleware B
Middleware C
Middleware C Ends
Middleware B Ends
Middleware A Ends

Running with Aker's own listen function

Aker.Listen starts a http server

Function Signature: Listen(PORT, CALLBACK)

CALLBACK is ran using goroutine

Author

aker's People

Contributors

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