Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
github.com/abiiranathan/rex
rex is a minimalistic but robust HTTP router built on Go 1.22’s enhanced http.ServeMux
. It offers a range of features for rapid web application development, including:
rex.FormScanner
interface.validator
package.r.SPA
to serve a single-page application.slog
package.rex.Handler
.r.Static
to serve static files from a directory or r.StaticFS
to serve files from a http.FileSystem
.
Both of these method can serve the minified version of the files if present and rex.ServeMinifiedAssetsIfPresent is set to true. You can also easily convert standard HTTP handlers to
rex
handlers:
rex.WrapHandler
to wrap a http.Handler
.rex.WrapFunc
to wrap a http.HandlerFunc
.rex.FormError
from r.BodyParser
and validator.ValidationErrors if there is a validation error.go get -u github.com/abiiranathan/rex
FormScanner
This example shows how to implement a custom type that satisfies the FormScanner
interface.
type Date time.Time // Date in format YYYY-MM-DD
// FormScan implements the FormScanner interface.
func (d *Date) FormScan(value interface{}) error {
v, ok := value.(string)
if !ok {
return fmt.Errorf("date value is not a string")
}
t, err := time.Parse("2006-01-02", v)
if err != nil {
return fmt.Errorf("invalid date format")
}
*d = Date(t)
return nil
}
For a complete example of template rendering and router usage, see the example in cmd/server/main.go.
rex includes a few external libraries, used only in the middleware subpackage. Explore the middleware package for more details and usage examples.
Run all tests with the following command:
go test -v ./...
Run benchmarks with memory profiling enabled:
go test -bench=. ./... -benchmem
Pull requests are welcome! For major changes, please open an issue to discuss your ideas first.
Don’t forget to update tests as needed.
This project is licensed under the MIT License.
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.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.