GoCondor is a golang web framework with an MVC like architecture, it's based on Gin framework

Overview

gocondor logo

GoCondor

Build Status Test Status GoDoc Go Report Card

What is GoCondor?

GoCondor is a golang web framework with an MVC like architecture, it's based on Gin framework, it features a simple organized directory structure for your next project with a pleasant development experience, made for developing modern APIs and microservices.

Features 

  • Router
  • Routing Groups
  • Middlewares
  • JWT tokens
  • ORM (GORM)
  • Sessions
  • Authentication
  • Cache (Redis)
  • TLS
  • Live-Reloading for development
  • Features Control

Architecture

The architecture is similar to MVC, where there is a routes file http/routes.go in which you can map all your app routes to their handlers. Handlers are simply methods that get executed when the matching request is received, you can think of it like a controller's action in MVC.

The request journey:

Request -> Routing -> Middleware -> Handler -> Middleware -> Json Response

Folder structure 

├── condor
│   ├── config/ ---------------> control what features to turn on
│   ├── httpd/-----------------> http related code
│   │   ├── handlers/ --------------> contains your requests handlers
│   │   ├── middlewares/ -----------> middlewares are defined here
│   ├── routes.go -------------> routes are mapped to their handlers here
│   ├── logs/ -----------------> logs file is here
│   ├── models/ ---------------> database models
│   ├── ssl/ ------------------> ssl certificates goes here
│   ├── .env ------------------> environment variables 
│   ├── .gitignore ------------> .gitignore file
│   ├── go.mod ----------------> Go modules that project depends on
│   ├── LICENSE ---------------> license
│   ├── main.go ---------------> main file
│   ├── README.md -------------> readme file

Installation

To create a new GoCondor project you need to install the gocondor cli first

Install GoCondor cli

To install the gocondor cli globally open up your terminal and run the following command:

go get github.com/gocondor/installer/gocondor

Create a new project:

The command for creating a new project is the following:

gocondor new [project-name] [project-location]

where: project-name is the name of your project project-location is the remote repository that will host the project, usually people use github.com

Now let's create a project with the name todo and let's assume it's hosted on the repository github.com/my-organization/todo, here is the command to create that project

gocondor new todo github.com/my-organization/todo

Getting started

Let's add the route /hello, and lets have hello there! as the response. To do that Open the file http/routes.go in your editor, update the function RegisterRoutes(), make sure the it looks like below:

func RegisterRoutes() {
    router := routing.Resolve()

    // Define your routes here
    router.Get("/hello", func(c *gin.Context) {
        message := "hello there!"

        c.JSON(http.StatusOK, gin.H{
            "message": message,
        })
    })
}

Next cd into the project folder and start the app by running the following command:

go run main.go

or you can start it using Air

air main.go

Finally, open up your browser and navigate to localhost:8000/hello.

To learn how to create handlers files and how to add handlers to them check handlers docs

Contribute

The framework consists of two main parts, each lives in a separate repository, the first part is the core which contains the framework core packages. the second part is gocondor which has the project folder structure and responsible of gluing everything together.

To contribute you simply need to clone these two repositories locally and create new branches from the develop branch, add your changes, then open up a PR to the develop branch.

Here is how you can clone and set up the development workflow in your local machine:

  1. Create the organization gocondor directory in your workspace, make sure the full path to it looks like below:
$GOPATH/src/ginthub.com/gocondor
  1. clone the repository core inside the organization gocondor directory:
git clone [email protected]:gocondor/core.git
  1. clone the repository gocondor:
git clone [email protected]:gocondor/gocondor.git
  1. cd into the project gocondor and open up go.mod in your editor and add the line github.com/gocondor/gocondor/core => [full-local-path-to-core] to the replacestatement, make sure it looks something like this:
module github.com/gocondor/gocondor

replace (
 github.com/gocondor/core => C:/Users/myname/go/src/github.com/gocondor/core

 github.com/gocondor/gocondor/config => ./config
 github.com/gocondor/gocondor/http => ./http
 github.com/gocondor/gocondor/http/middlewares => ./http/middlewares
 github.com/gocondor/gocondor/handlers => ./http/handlers
 github.com/gocondor/gocondor/models => ./models
)

Note: this is needed to tell go that instead of using the remote core package use the local copy where we will be making the changes, once you are done, open a PR to develop branch.

Issues
  • Where to add Authorization Files?

    Where to add Authorization Files?

    Hey there, your doing great work. I was trying to add casbin policies to work with the db, but i am having some issues since i have to initialize the gorm adapter gormadapter.NewAdapterByDB. Any help will be appreciated. Thanks in advance.

    opened by marijani101 3
  • Sqlite db not found

    Sqlite db not found

    Hello,

    it seems that there is an issue with the env key used to select the sqlite db to be used.

    it is written as. SQLITE_DB instead of SQLITE_FILE

    Also, while there, os.stats references ../../dbName instead of. dbName

    using gocondor version v1.1.0

    opened by marijani101 2
  • Adding Router Groups

    Adding Router Groups

    Is it possible to create router groups?

    ie: v1 := r.Group (v1)

    Then use it as normal for other routes

    ie: v1.Get("/users/all", handlers.UsersGetAll)

    Thanks in advance

    opened by marijani101 2
  • main.go's description is

    main.go's description is "ssl certificates"

    I wonder if you meant to have a different description for main.go

    In the readme it has this listed:

    │   ├── main.go ---------------> ssl certificates
    

    Would "program entrypoint" be more apt?

    opened by TechplexEngineer 1
Releases(v1.4.6)
Clean Architecture using Golang with Gin framework

Clean Architecture using Golang with Gin framework Template Structure Gin is a web framework written in Go (Golang). It features a martini-like API wi

Thanakorn Ariyagusolsuthi 7 Jun 6, 2022
Go-service-gin - Simple Web api application developed in Golang and Gin

Simple Web api application developed in Golang and Gin Initial Tutorial URL http

Nurul Huda Robin 0 Jan 4, 2022
Go (Golang) API REST with Gin FrameworkGo (Golang) API REST with Gin Framework

go-rest-api-aml-service Go (Golang) API REST with Gin Framework 1. Project Description Build REST APIs to support AML service with the support of exte

Tony Aizize 1 Nov 21, 2021
Golang rest API with MVC pattern, this job challenge is for the task for super_pay firm

Golang Rest Api with Docker Golang Gin Test Mvc Design Restapi let's start for build docker-compose up --build start docker-compose up stop docker-com

Dılo abinin yeri 4 Jun 12, 2022
Gin-boilerplate - This repository contains boilerplate code of a REST service using Gin (golang) framework.

Boilerplate REST service using Gin web framework (golang) Introduction This repository contains a boilerplate REST API service using Gin web framework

null 6 Apr 28, 2022
Implementation of clean architecture in golang with gin-gonic & gorm

Boilerplate API Boilerplate API template includes all the common packages and setup used for API development in this Company. Development Copy .env.ex

null 10 Feb 15, 2022
Gin-easy-todo - golang 의 RESTful API 프레임워크 gin 을 활용해 아주 간단한 Todo 애플리케이션을 만들어보자.

목차 1. 요약 2. 목표 3. API 목록 4. 프로젝트 구조 5. 패키지 별 기능과 관계 6. 사전 작업 6.1. DB, Table 생성 6.2. 모듈 생성 6.3. 패키지 다운로드 7. Gin 작성 7.1. 데이터베이스 설정 7.2. 테이블, 스키마 정의 7.3.

jongbae_park 0 Jan 2, 2022
Go-gin-mongo-api - A backend RESTful API built using golang, gin and mongoDB

go-gin-mongo-API This is a RESTful backend API which is developed using the gola

Humbe Jeffrey 4 Jun 24, 2022
Go-gin-ddd-cqrs - Clean api rest with Go, Gin and GORM

GOLANG API REST Clean api rest with Go, Gin and GORM. Clean Architecture with DD

Juan Cantón Rodríguez 10 May 28, 2022
Gin-boilerplate - Gin boilerplate preconfigured with basic rest api features

Gin Boilerplate Build apis with gin faster with this template Features Validatio

Mohan barman 3 Mar 31, 2022
Using golang framework (Gin) to create a web-application

News feeder Using golang framework (Gin) to create a web-application. This simpl

AmirH.Najafizadeh 1 Dec 20, 2021
Simple control panel for Golang based on Gin framework and MongoDB

Summer panel Simple control panel for Golang based on Gin framework and MongoDB How To Install go install github.com/night-codes/summer/[email protected]

Oleksiy Chechel 5 Nov 22, 2021
Simple web app using Go and Gin framework

go-gin-app Simple web app using Go and Gin framework Golang 과 Gin 프레임워크를 사용한 간단한 웹 앱 How to get Started Install Gin and have Go installed on your syst

Sean Hong(홍성민) 0 Oct 18, 2021
REST API for a shoe store using Go and Gin Web Framework

REST API for a shoe store using Go and Gin Web Framework This API uses a local PostgreSQL database that's set through the /gopostgres/driverConfig.go

Nalbert Wattam 0 Dec 26, 2021
ging is a tool for create gin web framework development templates

ging ging is a tool for create gin web framework development templates This tool is for the freshmen who want to learn golang and gin web framework, i

null 1 Jan 15, 2022
gin middlewares, just like nginx try-file function

Gin Middleware TryFile This project is to solve the problem that the gin framework processes the dynamic routing file in the front-end compilation fil

null 0 Jan 10, 2022
A simple blog based on gin framework

gin-blog 介绍 a simple blog based on gin framework 软件架构 MySQL/MariaDB as database 安装教程 基于Docker启动MySQL/MariaDB 使用说明 启动MySQL in Docker. 参与贡献 Fork 本仓库 新建

jimmyyem 0 Nov 15, 2021
Generates a simple skeleton directory structure for go/gin/bootstrap web apps

Gin Bootstrap Initializer Generates a simple skeleton directory structure for go/gin/bootstrap web apps Description This package handles building a co

Anthony hopkins 0 Jan 21, 2022
Automated penetration and auxiliary systems, providing XSS, XXE, DNS log, SSRF, RCE, web netcat and other Servers,gin-vue-admin

Simple DNS log Server,easy to ACME DNS challenge log easy send to elasticsearch https://github.com/hktalent/DNS_Server go4Hacker Automated penetration

51pwn 18 Jun 9, 2022