swagui

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2017 License: MIT Imports: 7 Imported by: 2

README

swagui

go get -u github.com/codemodus/swagui

Package swagui simplifies serving an instance of Swagger-UI. It can be added to a multiplexer, or served directly. If using a multiplexer, the path prefix option must match the relevant route.

Usage

type Options
type Swagui
    func New(opts *Options) (*Swagui, error)
    func (s *Swagui) Handler() http.Handler
    func (s *Swagui) PathPrefix() string
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)
        os.Exit(1)
    }

    // ...
}
With A Multiplexer
func main() {
    // ...

    m := http.NewServeMux()
    m.Handle("/some_path", someHandler)
    m.Handle(ui.PathPrefix(), ui.Handler())
    
    if err = http.ListenAndServe(":21234", m); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
    	
    // ...
}

More Info

Swagger Version

If an invalid version is configured (0, or > current release), the current release will be used.

Documentation

View the GoDoc

Benchmarks

N/A

Documentation

Overview

Package swagui simplifies serving an instance of Swagger-UI. It can be added to a multiplexer, or served directly. If using a multiplexer, the path prefix option must match the relevant route.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Version         int
	PathPrefix      string
	DefaultURLParam string
	NotFoundHandler http.Handler
}

Options holds optional Swagui data.

type Swagui

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

Swagui provides a Swagger-UI http.Handler and related data.

func New

func New(opts *Options) (*Swagui, error)

New returns a Swagui and defaults to the latest version of Swagger. If a path prefix is provided, it will be filtered for appropriate usage.

func (*Swagui) Handler

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

Handler returns an http.Handler which serves Swagger-UI.

func (*Swagui) PathPrefix

func (s *Swagui) PathPrefix() string

PathPrefix returns the current path prefix which has been filtered for appropriate usage.

Directories

Path Synopsis
cmd
swagui command
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.

Jump to

Keyboard shortcuts

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