inceptus

module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2020 License: MIT

README

inceptus

Docs Go Report Card License

The inceptus is (for now) a personal framework for making (web) servers in go..

The goal of inceptus is to have all you need to start making a new full stack web app (PWA with golang backend).

Just call bootstrap.sh and have all the boring boilerplate ready, so you can invest time in what actually matters..


Bootstraping

Clone this repo and follow the instructions in bootstrap.sh:

$./bootstrap.sh -h
Hey,
this script expects you already have existing git repository, into
which you want to bootstrap server based on inceptus server_template.

Usage:
    bootstrap.sh -h Display this help message.

    bootstrap.sh -n PROJECT_NAME -r REPOSITORY -d DIRECTORY
    where:
    - PROJECT_NAME will be used instead of "server_template"
    - REPOSITORY (like github.com/XXX/YYY) will be used instead of:
      "github.com/robitx/inceptus/server_template"
    - DIRECTORY is a folder where you want to boostrap the server:
      ├── cmd
      │   └── server
      │       └── main.go
      ├── conf
      │   ├── server_template.env
      │   └── server_template.yaml
      ├── internal
      │   ├── do
      │   │   └── do.go
      │   ├── env
      │   │   ├── config.go
      │   │   └── environment.go
      │   └── rest
      │       └── rest.go
      ├── main
      └── static
          ├── errors
          │   └── 404.html
          └── index.html
      ...

Local

Starting local instance of the server:

go build ./cmd/server/main.go; ./main -c conf/server_template.yaml

Trying the api:

url -D - -v -X GET localhost:9999/api/v1/echo -H "x-request-ids: requestID_XYZ" -H "accessToken: JWT_HERE" -d 'hey!'

For static site hello world go to http://localhost:9999/static/


Docker

Build:

docker build --tag server_template -f ./server_template.Dockerfile ./

Run:

docker run  --rm --name server_template -p 127.0.0.1:8080:8080 server_template:latest

Interactive shell:

docker exec -ti server_template sh

Directories

Path Synopsis
Package conf provide functions for loading config from yaml file or env variables
Package conf provide functions for loading config from yaml file or env variables
Package helpers contains some useful functions, currently: generating uuid, md5 from string, sourceIp
Package helpers contains some useful functions, currently: generating uuid, md5 from string, sourceIp
Package life provides application wide context with cancel function and some helper functions to register syscalls for smooth app termination and reloading (conf, logger and such)
Package life provides application wide context with cancel function and some helper functions to register syscalls for smooth app termination and reloading (conf, logger and such)
Package route and its subpackages provides most of what you need for http server
Package route and its subpackages provides most of what you need for http server
ctx
Package ctx contains setters and getters for request context
Package ctx contains setters and getters for request context
middleware
Package middleware contains middlewares for logging, auth, custom errors and so on
Package middleware contains middlewares for logging, auth, custom errors and so on

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL