-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (34 loc) · 1.02 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"cep-consult/api/config/middleware"
"cep-consult/api/handle"
"fmt"
"github.com/labstack/echo/v4"
echoSwagger "github.com/swaggo/echo-swagger"
)
// @title CEP Consult API
// @description This is a simple API for address lookup based on CEP
// @version 1
// @host localhost:8080
// @BasePath /v1
func main() {
e := echo.New()
// Middleware CORS
e.Use(middleware.CORS())
// Swagger documentation route
e.GET("/swagger/*", echoSwagger.WrapHandler)
// ConsultAddress Route and documentation
// @Summary Consult a CEP and return its address
// @Description Consult a CEP and return its address
// @ID consult-address
// @Accept json
// @Produce json
// @Param cep body string true "CEP to consult"
// @Success 200 {object} AddressResponse
// @Failure 400 {string} string "Invalid Request"
// @Failure 404 {string} string "CEP not found"
// @Router /consult-address [post]
e.POST("/v1/consult-address", handle.ConsultAddress)
fmt.Println("Running Port:8080")
e.Logger.Fatal(e.Start(":8080"))
}