GithubHelp home page GithubHelp logo

go-masonry / mortar-template Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 1.0 80 KB

Mortar template service

Home Page: https://go-masonry.github.io

License: MIT License

Makefile 8.66% Go 91.34%
mortar template

mortar-template's Introduction

Mortar service template

This is a gRPC web service template using Mortar

For documentations and internals read here

First steps

Once you download/clone this template, do the following

  1. (Optional) When it's not yet a git repository

    Init Git and create a first commit, before any other changes

    git init
    git add -A
    git commit -m "initial commit"
  2. (Optional) Download and install protoc compiler plugins if needed

    make go-install-deps

    This will install [protoc-gen-grpc-gateway, protoc-gen-openapiv2, protoc-gen-go, protoc-gen-go-grpc]. For more information read this

  3. Start you service

    make run
  4. Verify

    from a different shell but in the same directory

    • GRPC

      grpcurl -plaintext \
              --import-path ./api \
              --import-path ./third_party/googleapis \
              -proto helloworld.proto \
              -d '{"name":"Mortar"}' \
              "localhost:5380" helloworld.Greeter/SayHello

      It's output should be

      {
          "message": "Hello Mortar"
      }
    • Public REST API

      curl -XPOST -d '{"name": "Mortar"}' 'localhost:5381/v1/sayhello'

      It's output should be

      {
          "message": "Hello Mortar"
      }
    • Private API

      curl localhost:5382/self/build

      And you should see something like this

      {
      "git_commit": "5ebdaee",
      "version": "v1.2.3",
      "build_tag": "42",
      "build_time": "2021-01-30T15:47:15Z",
      "init_time": "2021-01-30T17:47:17.166625+02:00",
      "up_time": "1m24.145705728s",
      "hostname": "Tals-Mac-mini.lan"
      }

    Server can be stopped with CTRL+C

Mortar configurations

Everything related to Mortar setup and other Constructors are found in app/mortar/*.

Continue reading here

Changing your API

This is a template project and as such it makes assumptions you will probably going to change.

By default this template comes as a github.com/go-masonry/mortar-template go module.

You will need to change:

  1. GO Module

    Delete go.mod and go.sum and recreate with the package name of your choice.

  2. Imports

    By default this template API is compiled with the above import. Change api/*.proto files and recompile by running

    make gen-api
  3. Find & Replace/Update

    github.com/go-masonry/mortar-template -> <your-module-name>

Troubleshooting

  1. protoc-gen-go: program not found or is not executable means that $GOBIN is not in your $PATH

    Identify your GOPATH

    go env | grep GOPATH

    Set

    • For fish shell

      set -U fish_user_paths $GOPATH/bin $fish_user_paths
    • For zsh

      echo "export $GOPATH/bin:$PATH" >> ~/.zsh
  2. Init Git and create a first commit.

    If not you will see something similar in your logs:

    git="fatal: not a git repository (or any of the parent directories): .git"

mortar-template's People

Contributors

bevgene avatar evgenebruter-zoomin avatar talgendler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

vcnwafor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.