-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Yinebeb-01/gmain
Gmain
- Loading branch information
Showing
28 changed files
with
753 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
stages: | ||
- test | ||
|
||
image: golang:1.19 | ||
|
||
.go-cache: | ||
variables: | ||
GOPATH: $CI_PROJECT_DIR/.go | ||
before_script: | ||
- mkdir -p .go | ||
cache: | ||
paths: | ||
- .go/pkg/mod/ | ||
|
||
test: | ||
extends: .go-cache | ||
stage: test | ||
image: golang:latest | ||
tags: | ||
- gitlab-runner | ||
script: | ||
- go test . | ||
- go test ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
swag: | ||
swag init -g cmd/main.go | ||
|
||
test: | ||
go test -v -cover ./test/... | ||
|
||
run: | ||
go run ./cmd/main.go | ||
|
||
build: | ||
rm app | ||
go build -o app ./cmd/main.go | ||
|
||
.PHONY: swag test run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,76 @@ | ||
# ethiopianDateConverter | ||
<p align="center"> | ||
<img src="internal/assets/logo_medium.png" alt="logo" width="110" height="110"> | ||
</p> | ||
<h1 align="center"><a href="https://pkg.go.dev/gitlab.com/Yinebeb-01/ethiopiandateconverter">Ethiopian Date Converter</a></h1> | ||
|
||
## Description | ||
This mini-project s used mainly to convert Ethiopian date(yy-mm-dd) into Gregorian and vise versa. | ||
Ethiopia has its own calander, having 13 months and always have 30 days within a month. | ||
Anybody can use this api; it has easy to use, simply by sending the date along the predefined endpoints,one can get the date as a JSON response. | ||
* [wikipedia](https://en.wikipedia.org/wiki/Ethiopian_calendar) | ||
The Ethiopian Date Converter API is designed to facilitate the conversion between Ethiopian dates | ||
(in the format yy-mm-dd) and Gregorian dates. Ethiopia follows its own calendar system, which consists of 13 months, | ||
each with 30 days. | ||
|
||
### contents | ||
If you are newbie to golang, this project will guide and help you on testing(BDD-with Godog), using gin weebframwork and more. | ||
### Functionality | ||
This API allows users to: | ||
* Convert Ethiopian dates to Gregorian dates. | ||
* Convert Gregorian dates to Ethiopian dates. | ||
|
||
## Installation | ||
### Usage | ||
To utilize the API, simply send a date using the specified endpoints. The API will respond with the converted date | ||
in JSON format. | ||
|
||
#### Example Usage | ||
|
||
1. Convert Gregorian Date to Ethiopian Date | ||
|
||
```curl | ||
GET /ad-to-et/{date} | ||
``` | ||
|
||
* Parameters: | ||
|
||
`date:` The Gregorian date to convert (in _yy-mm-dd_ format). | ||
|
||
1. install using below go command: | ||
- ```go get gitlab.com/Yinebeb-01/ethiopiandateconverter``` | ||
**Example**: | ||
|
||
2. import onto your project code | ||
- ```import "gitlab.com/Yinebeb-01/ethiopiandateconverter"``` | ||
```curl | ||
GET /ad-to-et/2013-09-11 | ||
``` | ||
|
||
## Authors and acknowledgment | ||
- [Yinebeb T.](https://gitlab.com/Yinebeb-01/) | ||
Response: | ||
|
||
- You can check the [python version](https://github.com/dimagi/ethiopian-date-converter) | ||
```json | ||
{ | ||
"gregorian_date": "2021-05-22" | ||
} | ||
``` | ||
|
||
## Documentation | ||
Read on [pkg.go.dev](https://pkg.go.dev/gitlab.com/Yinebeb-01/ethiopiandateconverter) | ||
2. Convert Gregorian Date to Ethiopian Date | ||
|
||
```curl | ||
GET /et-to-ad/{date} | ||
``` | ||
|
||
* Parameters: | ||
|
||
`date:` The Ethiopia date to convert (in _yy-mm-dd_ format). | ||
|
||
**Example**: | ||
```curl | ||
GET /et-to-ad/2021-05-22 | ||
``` | ||
Response: | ||
```json | ||
{ | ||
"ethiopian_date": "2013-09-11" | ||
} | ||
``` | ||
|
||
## Installation | ||
|
||
## Project status | ||
First version, I will come soon with updates | ||
Install using below go command: | ||
```bash | ||
go get gitlab.com/Yinebeb-01/ethiopiandateconverter | ||
``` | ||
|
||
## Author | ||
- [Yinebeb T.](https://github.com/Yinebeb-01/) | ||
- [python version](https://github.com/dimagi/ethiopian-date-converter) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Ethiopian Calendar tool for Golang | ||
Copyright (c) 2022 Yinebeb Tariku <[email protected]> | ||
*/ | ||
package main | ||
|
||
import ( | ||
"github.com/Yinebeb-01/ethiopiandateconverter/config" | ||
"github.com/Yinebeb-01/ethiopiandateconverter/docs" | ||
"github.com/Yinebeb-01/ethiopiandateconverter/internal/api" | ||
"github.com/gin-gonic/gin" | ||
"github.com/spf13/viper" | ||
swaggerFiles "github.com/swaggo/files" | ||
ginSwagger "github.com/swaggo/gin-swagger" | ||
) | ||
|
||
// @title EthioGrego | ||
// @version 1.0 | ||
// @description Ethiopian to Gregorian date converter server. | ||
// @termsOfService https://st-son.com/terms/ | ||
// @contact.name API Support | ||
// @contact.url https://st-son.com/support | ||
// @contact.email [email protected] | ||
// @license.name Apache 2.0 | ||
// @license.url https://www.apache.org/licenses/LICENSE-2.0.html | ||
// @host calendar.st-son.com | ||
// @BasePath /v1 | ||
// @securityDefinitions.basic BasicAuth | ||
func main() { | ||
config.InitConfig("config/config.yaml") | ||
docs.SwaggerInfo.Schemes = viper.GetStringSlice("server.schemes") | ||
docs.SwaggerInfo.Host = viper.GetString("server.host") | ||
|
||
router := gin.Default() | ||
docs.SwaggerInfo.BasePath = "/v1" | ||
router.Static("/assets", "./internal/assets") | ||
router.StaticFile("favicon.ico", "internal/assets/favicon.ico") | ||
v1 := router.Group(docs.SwaggerInfo.BasePath) | ||
{ | ||
v1.GET("", api.HomePage) | ||
v1.GET("/et-to-ad/:date", api.Gregorian) | ||
v1.GET("/ad-to-et/:date", api.Ethiopian) | ||
|
||
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) | ||
} | ||
|
||
router.Run(":8080") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package config | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/fsnotify/fsnotify" | ||
"github.com/spf13/viper" | ||
"go.uber.org/zap" | ||
"log" | ||
) | ||
|
||
func InitConfig(path string) { | ||
viper.SetConfigFile(path) | ||
err := viper.ReadInConfig() | ||
if err != nil { | ||
log.Panic(context.Background(), fmt.Sprintf("Failed to read config: %v", err)) | ||
} | ||
|
||
viper.WatchConfig() | ||
viper.OnConfigChange(func(e fsnotify.Event) { | ||
log.Panic(context.Background(), "Config file changed:", zap.String("file", e.Name)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
server: | ||
host: localhost:8080 | ||
schemes: | ||
- http | ||
- https |
Oops, something went wrong.