command
module
Version:
v0.0.0-...-e224c93
Opens a new window with list of versions in this module.
Published: Sep 1, 2023
License: Apache-2.0
Opens a new window with license information.
Imports: 11
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
Example: REST server
Simple HTTP/JSON REST server implemented in Go, using go-chi for HTTP routing.
To run this, cd to the root of this git repo, then run these steps:
-
cd into an empty directory
$ mkdir ~/template_tmp
$ cd ~/template_tmp
-
Install the abc
binary
$ go install github.com/abcxyz/abc/cmd/abc@latest
$ abc --help
This only works if you have go installed (https://go.dev/doc/install) and have the Go binary directory in your $PATH (try PATH=$PATH:~/go/bin).
-
Execute the template defined in the t
directory.
This will output a file named main.go
in your working directory containing
the transformed program.
$ abc templates render github.com/abcxyz/abc.git//t/rest_server
-
Run the transformed program:
$ go run .
[yyyy/mm/dd hh:mm:ss] starting server on 8080
-
In a separate shell, run:
$ curl localhost:8080
{"message":"hello world"}
Documentation
¶
Package main implements a simple HTTP/JSON REST example.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.