acacia

module
v0.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2023 License: MIT

README

alt text

golang license

About

Acacia is lightweight package that will help you to route http server. Acacia route the path based on tree data structure. This package also support parameters in the path, so it will help you to build http routing with some parameters. in the path

Install

$ go get github.com/MeiSastraJayadi/acacia


Router

Create New Router

router := multiplexer.NewRouter("/")

Add Prefix to the Router

SetPrefix will add a prefix into the router path. the parameter that will be accept in function SetPrefix is just a string
router := multiplexer.NewRouter("/")
router.SetPrefix("product")

Add Some Methods

With Router.Methods(), some methods will be added into the router. The methods can be added more than just one method if the router can handle more than one methods
router := multiplexer.NewRouter("/")
routerPost := router.Methods(http.MethodsPost)
Or
router := multiplexer.NewRouter("/")
routerPost := router.Methods(http.MethodsPost, http.MethodGet)

Add Subrouter

A router can be added some subrouter from another router. To do that, what you can do is
router := multiplexer.NewRouter("/")
routerPost := router.Methods(http.MethodsPost, http.MethodGet)

subrouter := multiplexer.NewRouter("/") 
subrouter.SetPrefix("product")
subrouterPost := subrouter.Methods(http.MethodGet)
router.SubRouter(subrouter)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL