custom-server/

directory
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2018 License: Apache-2.0

README

Go-Swagger: Custom Server Example

An example project, showcasing how one can create a custom OpenAPI-based Go server, using go-swagger to generate its core.

You can regenerate the ./gen directory using the swagger cli:

$ rm -rf gen && swagger generate server --exclude-main -A greeter -t gen -f ./swagger/swagger.yml

Running the greeter server on port 3000 is as simple as:

$ go run ./cmd/greeter/main.go --port 3000

You can test the server using httpie as follows:

$ http get :3000/hello                  # returns 'Hello, World!'
$ http get :3000/hello name==Swagger    # returns 'Hello, Swagger!'

Directories

Path Synopsis
cmd
gen
restapi
Package restapi Greeting Server Schemes: http Host: localhost BasePath: / Version: 1.0.0 Consumes: - application/json Produces: - text/plain swagger:meta
Package restapi Greeting Server Schemes: http Host: localhost BasePath: / Version: 1.0.0 Consumes: - application/json Produces: - text/plain swagger:meta

Jump to

Keyboard shortcuts

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