https://github.com/codesqueak/golangexamplerestserver
An example REST server built using Golang
https://github.com/codesqueak/golangexamplerestserver
example golang rest restful-api
Last synced: 3 months ago
JSON representation
An example REST server built using Golang
- Host: GitHub
- URL: https://github.com/codesqueak/golangexamplerestserver
- Owner: codesqueak
- License: mit
- Created: 2022-06-26T15:53:35.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-08T00:31:00.000Z (almost 3 years ago)
- Last Synced: 2025-01-22T21:44:53.973Z (4 months ago)
- Topics: example, golang, rest, restful-api
- Language: Go
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Example REST Processing in Go
This project demonstrates how to handle each HTTP Verb using go
It includes examples of:
- GET / POST / PUT / PATCH / DELETE / HEAD verb handling
- Query parameters
- URL parameters
- JSON Marshal / Unmarshal processing
- Error handling
- File retrieval
- ETag generation
- Swagger usage
- ... anything else i can think of and have time to include## Install Swagger Tooling
```
dir=$(mktemp -d)
git clone https://github.com/go-swagger/go-swagger "$dir"
cd "$dir"
go install ./cmd/swagger
```
## Default Swagger Project Pagehttp://localhost:8090/docs
## Various Components used
OpenAPI project for golang
[OpenAPI Initiative golang toolkit](https://github.com/go-openapi)
The runtime component for use in codegeneration or as untyped usage.
[openapi runtime interfaces](https://github.com/go-openapi)
```
go get github.com/go-openapi/runtime/middleware
```
Gorilla is a web toolkit for the Go programming language that provides useful, composable packages for writing HTTP-based applications.[Gorilla Web Toolkit](https://github.com/gorilla)
```
go get -u github.com/gorilla/mux
```
## Generate Swagger YAML
```
swagger generate spec -o ./swagger.yaml --scan-models
```
## CoffeeIf you find this project useful, you may want to [__Buy me a Coffee!__ :coffee:](https://www.buymeacoffee.com/codesqueak) Thanks :thumbsup: