Skip to content

net/http backend template

go version go cover go report license

Package net provides a portable interface for network I/O, including TCP/IP, UDP, domain name resolution, and Unix domain sockets. Package net/http provides HTTP client and server implementations.

  • Create a new project:
cgapp create
  • Run project by this command:
task -s

What's task command?

We're using Taskfile1 as task manager for running project on a local machine by default.

.
├── .dockerignore
├── .editorconfig
├── .gitignore
├── Dockerfile
├── Taskfile.yml
├── go.mod
├── go.sum
├── main.go
├── configs
│   └── apiserver.yml
├── static
│   └── index.html
└── pkg
    └── apiserver
        ├── config.go
        ├── config_test.go
        ├── error_checker.go
        ├── error_checker_test.go
        ├── new_server.go
        ├── new_server_test.go
        ├── utils.go
        ├── utils_test.go
        └── routes.go

4 directories, 17 files
# ./configs/apiserver.yml

# Server config
server:
    host: 0.0.0.0
    port: 5000

# Database config
database:
    host: 127.0.0.1
    port: 5432
    username: postgres
    password: 1234

# Static files config
static:
    prefix: /
    path: ./static

  1. If you've never heard of Taskfile, we recommend to read the Docs and use it, instead of Makefile