Skip to content

codemodus/swagui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swagui

go get -u github.com/codemodus/swagui

Package swagui simplifies serving an instance of Swagger-UI.

Usage

type Options
type Swagui
    func New(opts *Options) (*Swagui, error)
    func (s *Swagui) Handler() http.Handler
type Version

Setup

import (
    // ...

    "github.com/codemodus/swagui"
)

func main() {
    // ...
    
    ui, err := swagui.New(nil)
    if err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }

    if err = http.ListenAndServe(":21234", ui.Handler("")); err != nil {
        fmt.Fprintln(os.Stderr, err)
    }

    // ...
}

With A Multiplexer

func main() {
    // ...

    m := http.NewServeMux()
    // ...

    m.Handle("/some_path", someHandler)
    m.Handle(
        "/docs/", 
        http.StripPrefix("/docs/", ui.Handler("/defs/swagger.json")),
    )
    
    if err = http.ListenAndServe(":21234", m); err != nil {
        fmt.Fprintln(os.Stderr, err)
    }
    	
    // ...
}

More Info

N/A

Documentation

View the GoDoc

Benchmarks

N/A

About

Simple serving of an instance of Swagger-UI

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages