swagui

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: MIT Imports: 2 Imported by: 2

README

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

Documentation

Overview

Package swagui simplifies serving an instance of Swagger-UI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider added in v0.3.0

type Provider interface {
	Handler(notFound http.Handler, defaultDef string) http.Handler
}

Provider sets up an HTTP handler for Swagger-UI resources. The provided types that implement this interface are located in separate packages based on their Swagger version so that imported dependencies are controlled by the caller.

type Swagui

type Swagui struct {
	// contains filtered or unexported fields
}

Swagui wraps a Provider to simplify usage.

func New

func New(notFound http.Handler, p Provider) (*Swagui, error)

New returns a Swagui, or an error if no provider is set.

func (*Swagui) Handler

func (s *Swagui) Handler(defaultDefinition string) http.Handler

Handler returns an http.Handler for Swagger-UI resources.

Directories

Path Synopsis
cmd
swagui
swagui is a basic implementation of the swagui library which simplifies serving an instance of Swagger-UI.
swagui is a basic implementation of the swagui library which simplifies serving an instance of Swagger-UI.
internal
Code generated by go-bindata.
Code generated by go-bindata.
Code generated by go-bindata.
Code generated by go-bindata.
Code generated by go-bindata.
Code generated by go-bindata.

Jump to

Keyboard shortcuts

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