GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Tejaswi-cloud/go-webapp-sample: golang, echo, gorm

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

296 Commits
296 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
config
config
 
 
container
container
 
 
controller
controller
 
 
docs
docs
 
 
logger
logger
 
 
middleware
middleware
 
 
migration
migration
 
 
model
model
 
 
public
public
 
 
repository
repository
 
 
router
router
 
 
service
service
 
 
session
session
 
 
test
test
 
 
util
util
 
 
.gitignore
.gitignore
 
 
.goreleaser.yml
.goreleaser.yml
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
Dockerfile
Dockerfile
 
 
Jenkinsfile
Jenkinsfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
application.develop.yml
application.develop.yml
 
 
application.docker.yml
application.docker.yml
 
 
application.k8s.yml
application.k8s.yml
 
 
go-webapp-sample
go-webapp-sample
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
main.go
main.go
 
 
zaplogger.develop.yml
zaplogger.develop.yml
 
 
zaplogger.docker.yml
zaplogger.docker.yml
 
 
zaplogger.k8s.yml
zaplogger.k8s.yml
 
 

Repository files navigation

go-webapp-sample

license report workflow release

Preface

This repository is the sample of web application using golang. This sample uses Echo as web application framework, Gorm as OR mapper and Zap logger as logger. This sample application provides only several functions as Web APIs. Please refer to the 'Service' section about the detail of those functions.

Also, this application contains the static contents such as html file, css file and javascript file which built vuejs-webapp-sample project to easily check the behavior of those functions. So, you can check this application without starting a web server for front end. Please refer to the 'Starting Server' section about checking the behavior of this application.

If you would like to develop a web application using golang, please feel free to use this sample.

Install

Perform the following steps:

  1. Download and install MinGW(gcc).
  2. Download and install Visual Studio Code(VS Code).
  3. Download and install Golang.
  4. Get the source code of this repository by the following command.
    go get -u github.com/ybkuroki/go-webapp-sample

Starting Server

There are 2 methods for starting server.

Without Web Server

  1. Starting this web application by the following command.
    go run main.go
  2. When startup is complete, the console shows the following message:
    http server started on [::]:8080
    
  3. Access http://localhost:8080 in your browser.
  4. Login with the following username and password.
    • username : test
    • password : test

With Web Server

Starting Application Server

  1. Starting this web application by the following command.
    go run main.go
  2. When startup is complete, the console shows the following message:
    http server started on [::]:8080
    
  3. Access http://localhost:8080/api/health in your browser and confirm that this application has started.
    healthy
    

Starting Web Server

  1. Clone vuejs-webapp-sample project and install some tools.
  2. Start by the following command.
    npm run serve
  3. When startup is complete, the console shows the following message:
    DONE Compiled successfully in *****ms
    
    App running at:
    - Local:   http://localhost:3000/
    - Network: http://192.168.***.***:3000/
    
    Note that the development build is not optimized.
    To create a production build, run npm run build.
    
  4. Access http://localhost:3000 in your browser.
  5. Login with the following username and password.
    • username : test
    • password : test

Using Swagger

In this sample, Swagger is enabled only when executed this application on the development environment. Swagger isn't enabled on the another environments in default.

Accessing to Swagger

  1. Start this application according to the 'Starting Application Server' section.
  2. Access http://localhost:8080/swagger/index.html in your browser.

Updating the existing Swagger document

  1. Update some comments of some controllers.
  2. Download Swag library. (Only first time)
    go get github.com/swaggo/swag/cmd/swag
  3. Update docs/docs.go.
    swag init

Build executable file

Build this source code by the following command.

go build main.go

Project Map

The follwing figure is the map of this sample project.

- go-webapp-sample
  + config                  … Define configurations of this system.
  + logger                  … Provide loggers.
  + middleware              … Define custom middleware.
  + migration               … Provide database migration service for development.
  + router                  … Define routing.
  + controller              … Define controllers.
  + model                   … Define models.
  + repository              … Provide a service of database access.
  + service                 … Provide a service of book management.
  + session                 … Provide session management.
  + test                    … for unit test
  - main.go                 … Entry Point.

Services

This sample provides 3 services: book management, account management, and master management. Regarding the detail of the API specification, please refer to the 'Using Swagger' section.

Book Management

There are the following services in the book management.

Service Name HTTP Method URL Parameter Summary
Get Service GET /api/books/[BOOK_ID] Book ID Get a book data.
List/Search Service GET /api/books?query=[KEYWORD]&page=[PAGE_NUMBER]&size=[PAGE_SIZE] Page, Keyword(Optional) Get a list of books.
Regist Service POST /api/books Book Regist a book data.
Edit Service PUT /api/books Book Edit a book data.
Delete Service DELETE /api/books Book Delete a book data.

Account Management

There are the following services in the Account management.

Service Name HTTP Method URL Parameter Summary
Login Service POST /api/auth/login Session ID, User Name, Password Session authentication with username and password.
Logout Service POST /api/auth/logout Session ID Logout a user.
Login Status Check Service GET /api/auth/loginStatus Session ID Check if the user is logged in.
Login Username Service GET /api/auth/loginAccount Session ID Get the login user's username.

Master Management

There are the following services in the Master management.

Service Name HTTP Method URL Parameter Summary
Category List Service GET /api/categories Nothing Get a list of categories.
Format List Service GET /api/formats Nothing Get a list of formats.

Libraries

This sample uses the following libraries.

Library Name Version
echo 4.6.1
gorm 1.22.3
go-playground/validator.v9 9.31.0
zap 1.19.1

Contribution

Please read CONTRIBUTING.md for proposing new functions, reporting bugs and submitting pull requests before contributing to this repository.

License

The License of this sample is MIT License.

About

golang, echo, gorm

Resources

Readme
License

Contributing

Contributing
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.