feat(http): add HTTP router and utility functions with Bangla support - #52
Conversation
- Implemented `router_banao` to create a new router with various HTTP methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS) using Bangla keywords. - Added middleware support with `majhe` for handling requests. - Introduced `bebohar` for mounting sub-routers. - Implemented CORS support with `cors_chharpao` for handling cross-origin requests. - Added static file serving with `file_dao`. - Implemented redirection with `ghurao` and cookie management with `kuki_rakho`. - Added HTML response serving with `html_uttor`. - Introduced logging support with `log_chalu`. - Enhanced tests for new features including path parameters, query parameters, middleware, CORS, static files, redirection, cookies, and full production stack. - Updated version to 9.3.0.
🤖 Review Buddy - General Code Review
Oho @AnkanSaha bhai! Express.js ko Bengali dhoti pehna di? Kya baat hai! 👏 Pranaam! Aapne toh pura web framework hi bana diya BanglaCode ke liye. Bugs aur Issues:
Overall, feature list toh lambi hai, par stability thodi 'khali' (empty) hai. Code Quality Score: 6/10 (Points for the Bengali creativity, but minus points for memory management and performance). Generated by Review Buddy | Tone: roast | Language: hinglish |
⚡ Review Buddy - Performance Analysis
Arre bhai! Performance ke naam pe aapne toh 'pishi' (auntie) ki slow walk wala logic likha hai. Chalo, detail mein batata hoon kyun aapka code production mein 'dhishoom' ho jayega:
Recommendation:
Generated by Review Buddy | Tone: roast | Language: hinglish |
🔐 Review Buddy - Security Audit
Oye! Security ke maamle mein toh tumne 'khula darwaza' policy rakhi hai.
OWASP References:
Generated by Review Buddy | Tone: roast | Language: hinglish |
📊 Review Buddy - Code Quality & Maintainability Analysis
🎯 Overall Benchmark: 55/100 (Needs Improvement)Bhai, code quality dekh ke lag raha hai tumne 'Express.js' ko Google Translate karke Go mein chaap diya hai. Chalo, 'Bangla Express' ka post-mortem karte hain:
Example of Refactoring: // Current: Recursive execution
execute = func(idx int) {
if idx < len(middlewares) {
// ... logic
callHandler(mw, []object.Object{reqMap, resMap, nextFn})
}
}
// Better: Iterative or wrapped handlers (like Gin/Echo)Generated by Review Buddy | Tone: roast | Language: hinglish |
💡 Review Buddy - Best Practices & Alternative Suggestions
Arre Ankan! Best practices follow karna toh 'Sotti' (sach mein) bhul gaye tum. Dekho ye examples: 1. HTTP Client ReuseCurrent Code: client := &http.Client{}
return client.Do(req)Better Alternative: // Global variable
var defaultHTTPClient = &http.Client{
Timeout: time.Second * 30,
Transport: &http.Transport{
MaxIdleConns: 100,
IdleConnectionTimeout: 90 * time.Second,
},
}
// In function:
return defaultHTTPClient.Do(req)Why: Connection pooling. Bina iske aapka server sockets exhaust kar dega within minutes under load. 2. Map Initialization with CapacityCurrent Code: pairs := make(map[string]object.Object)Better Alternative: pairs := make(map[string]object.Object, len(v))Why: Performance. Agar size pata hai toh capacity pehle hi batado, warna map resize hone mein CPU cycles waste honge. 3. Middleware ExecutionCurrent Code: // Recursive closure `execute` inside ServeHTTPBetter Alternative: 4. String Concatenation in LoopsCurrent Code: regexParts = append(regexParts, regexp.QuoteMeta(part))
// ... strings.Join laterWhy: This is actually fine (strings.Join is good), but watch out for other places where you use Generated by Review Buddy | Tone: roast | Language: hinglish |
|
router_banaoto create a new router with various HTTP methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS) using Bangla keywords.majhefor handling requests.beboharfor mounting sub-routers.cors_chharpaofor handling cross-origin requests.file_dao.ghuraoand cookie management withkuki_rakho.html_uttor.log_chalu.Description
Related Issue
Fixes #
Type of Change
Changes Made
How Has This Been Tested?
./banglacode examples/*.bang)Test Commands
# Commands used to test ./banglacode examples/hello.bangScreenshots (if applicable)
Checklist
Code Quality
Documentation
Testing
Other
Additional Notes
Commit Message Format
Please ensure your commit messages follow this format:
Types:
feat,fix,docs,test,refactor,perf,choreNeed Help?
If you need help with anything, please don't hesitate to ask in the PR comments or in GitHub Discussions.