Code Monkey home page Code Monkey logo

g-route's Introduction

Modular Route Handling For Golang

This is a simple example of a Go web application demonstrating modular route handling using the net/http with golang 1.22+

Overview

This project illustrates how to organize a Go web application with multiple controllers, each responsible for handling specific routes. The goal is to keep the codebase clean, modular, and easy to maintain.

Features

  • Modular Route Handling: Controllers are organized into separate files, making it easy to manage routes for different parts of the application.
  • Centralized Route Definition: Routes are defined in a central location (routes.go), where controllers register themselves with the router.
  • Controller Interface: All controllers implement a BaseController interface, ensuring consistency and structure across the application.

Structure

    .
    ├── controllers
    │ ├── BaseController.go
    │ └── *Controller.go # OtherControllers
    ├── main.go
    ├── README.md
    └── LICENCE.md

Advantages

just add all controllers with single line like controller.RegisterRoutes(mux)

  • Less Code Complexity: Just define a controller/handler on own file
  • Simplified Maintenance: Organizing routes into separate modules makes it easier to manage and maintain the codebase.
  • Enhanced Scalability: Can scale individual modules independently, allowing for better resource allocation and improved performance.
  • Improved Developer Experience: Developers can work on specific modules without needing to understand the entire application, reducing cognitive load and improving productivity.
  • Flexibility: Modules can be added, updated, or removed with minimal impact on other parts of the application, providing flexibility for future enhancements.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.

License

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.

g-route's People

Contributors

alaybey avatar ialaybey 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.