README

Welcome to 👋

Version

swagger를 쉽게 배포할 수 있도록 정의한 패키지

Install

go get github.com/realsangil/gopkg/swagger

Usage

Go Standard HTTP package

func main() {
  if err := http.ListenAndServe(":1202", HTTPHandleFunc("https://petstore.swagger.io/v2/swagger.json")); err != nil {
		panic(err)
	}
}

Echo framework

func main() {
  e := echo.New()
	e.GET("/docs", EchoHandleFunc("/v2/swagger.json", WithTitle("Example")))
	if err := e.Server.ListenAndServe(); err != nil {
		panic(err)
	}
}

Run tests

go test ./...

Author

👤 realsangil

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2020 realsangil.
This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator

Expand ▾ Collapse ▴

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func EchoHandleFunc

func EchoHandleFunc(specURL string, opts ...ParameterOption) echo.HandlerFunc

EchoHandleFunc returns echo.HandleFunc

Example

Code:

e := echo.New()
e.GET("/docs", EchoHandleFunc("/docs/spec", WithTitle("Example")))
if err := e.Server.ListenAndServe(); err != nil {
	panic(err)
}

func HTTPHandleFunc

func HTTPHandleFunc(specURL string, opts ...ParameterOption) http.HandlerFunc

HTTPHandleFunc returns http.HandlerFunc

Example

Code:

if err := http.ListenAndServe(":1202", HTTPHandleFunc("http://localhost:1324/docs/spec")); err != nil {
	panic(err)
}

Types

type Parameter

type Parameter struct {
	Title   string `json:"title,omitempty"`
	Favicon string `json:"favicon,omitempty"`
	SpecURL string `json:"spec_url,omitempty"`
}

Parameter is golang template parameter

type ParameterOption

type ParameterOption func(*Parameter)

ParameterOption sets Parameter fields

func WithFavicon

func WithFavicon(favicon string) ParameterOption

WithFavicon sets favicon url to Parameter.Favicon

func WithTitle

func WithTitle(title string) ParameterOption

WithTitle sets title to Parameter.Title

Source Files