Skip to content

huseyinbuyukdere/gobasicapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic Go Api Structure

gopherbadger-tag-do-not-edit

It provides you basic api structure for development.

Development

You can add your api to pkg/api folder and register api to service in main.go file like below.

If you want authorization by JWT you can set "IsPublic" flag as false but you need to modify login api for verify credentials.

var routes = []models.Route{
	models.Route{HandlerFunction: api.Login, Path: "/login", MethodName: "POST", IsPublic: true},
	models.Route{HandlerFunction: api.VerifyTest, Path: "/myNewApi", MethodName: "POST", IsPublic: false},
}

It includes logging middleware. Logging middleware is logging all requests to log file which seperated by date.

Run

You can run the service with the following command.

You need to set your service variables in .env file before run

In cmd folder

go run main.go

Releases

No releases published

Packages

No packages published