Coder Social home page Coder Social logo

faeshal / go-gin-simpleapi-cleanarchitecture Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fadilahonespot/go-gin-simpleapi-cleanarchitecture

0.0 0.0 0.0 17 KB

Clean arshitecture worker simple rest api with gin and gorm framework

Go 100.00%

go-gin-simpleapi-cleanarchitecture's Introduction

Simple API Clean Architecture With Gin and Gorm Framework

CRUD simple RESTFUL API with routing in using gin framework and ORM database with Gorm auto migrate. Database using mysql. Check config/config.go for configurate database. just create a database with the name simple_api in MySQL and then run this API program

Clean architecture divides our code into 4 layers

  • Model/entity: encapsulate enterprise wide business rules. An entity in Go is a set of data structures and functions.
  • Use Cases: the software in this layer contains application specific business rules. It encapsulates and implements all of the use cases of the system.
  • Repository: the software in this layer is a set of adapters that convert data from the format most convenient for the use cases and entities, to the format most convenient for some external agency such as the Database or the Web
  • Handler/Driver: this layer is generally composed of frameworks and tools such as the Database, the Web Framework, etc.

Installation

  • configure database in folder config/config.go
  • open the program via the terminal.
  • run the program by typing the command
go run main.go

Routing in API

Testing in localhost

  • GET Method
localhost:7861/person
  • GET Method by id
localhost:7861/person/id
example
localhost:7861/person/1
  • POST METHOD
localhost:7861/person

Input body

{
  "first_name": "Agung",
  "last_name": "Sanjaya"
}
  • PUT Method
localhost:7861/person/id

Input body #input ID will be used to update the data

{
  "first_name": "Novan",
  "last_name": "Gunawan"
}
  • DELETE METHOD by id
localhost:7861/person/id

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

go-gin-simpleapi-cleanarchitecture's People

Contributors

fadilahonespot 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.