Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
github.com/valstack-dev/go-trie-url-route
A very efficient and minimal HTTP Go router, using a Trie data structure for efficiency.
Based on https://github.com/ant0ine/go-json-rest with the kitchen-sink philosophy stuff removed (so much that I wouldn't particularly consider it a fork).
It aims to be the innermost handler in a composition of handlers. It doesn't require methods to have http.HandlerFunc signature, as route paths are interface{}.
go get github.com/mantasmatelis/go-route
import(
"net/http"
"github.com/mantasmatelis/go-trie-url-route")
var router route.Router
func main() {
router.SetRoutes(
route.Route{"POST", "/count/:Count", SetCount},
route.Route{"GET", "/count" GetCount},
route.Route{"POST", "/count", IncrementCount},
route.Route{"POST", "/reset", ResetCount},
)
http.ListenAndServe(":3000", http.HandlerFunc(handler))
}
func handler(w http.ResponseWriter, r *http.Request) {
route, params, pathMatched := router.FindRouteFromURL(r.Method, r.URL)
if route != nil {
route.Func.(func(http.ResponseWriter, *http.Request, map[string]string))(w, r, params)
}
}
...
How is this different from ant0ine/go-json-rest? This doesn't:
route.Func
is typecast before being called. Use this feature to pass a "Context" struct containing request information, like the authenticated user object, or pass the "params" in the url string.)It exposes the basic router so that your own stack of handlers can be easily written, customized to specific needs.
Enjoy! Pull requests maintaining the basic above philosophy are welcomed.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.