Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scraly/http-go-server
https://github.com/scraly/http-go-server
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/scraly/http-go-server
- Owner: scraly
- Created: 2019-10-28T06:55:10.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-04-04T21:12:06.000Z (over 1 year ago)
- Last Synced: 2024-06-19T00:30:41.063Z (5 months ago)
- Language: Go
- Size: 10.2 MB
- Stars: 16
- Watchers: 4
- Forks: 16
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# http-go-server
This repo contains a simple/basic HTTP server in Go, with a basic code organization.
We use:
* net/http package to start and serve HTTP server
* Gorilla mux to handle routes
* Swagger in lorder to serve a REST API compliant with OpenAPI specs## Pre-requisits
Install Go in 1.13 version minimum.
## Build the app
`$ go build -o bin/http-go-server internal/main.go`
or
`$ make build`
## Run the app
`$ ./bin/http-go-server`
## Test the app
```
$ curl http://localhost:8080/healthz
OK$ curl http://localhost:8080/hello/aurelie
```
### Request & Response Examples
Swagger doc: [http-go-server](https://github.com/scraly/http-go-server/doc/index.html)
| URL | Port | HTTP Method | Operation |
|:-------------------------:|:--------:|:-----------------------:|------------------------------------------------------------------------|
| /healthz | 8080 | GET | Test if the app is running |
| /hello/{name} | 8080 | GET | Returns message with {name} provided in the query | |`$ curl localhost:8080/hello/aurelie`
## Generate swagger files
After editing `pkg/swagger/swagger.yml` file you need to generate swagger files again:
`$ make gen.swagger`
## Test swagger file validity
`$ make swagger.validate`
## Generate swagger documentation
`$ make swagger.doc`