swagui

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 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.

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 Options

type Options struct {
	Version         Version
	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 manages related data.

func New

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

New returns a Swagui and defaults to the latest version of Swagger.

func (*Swagui) Handler

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

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

type Version added in v0.2.0

type Version int

Version wraps integer to ease the defining of the swagger ui version.

const (
	VNewest Version = iota
	V1
	V2
	V3
)

V{n} constants list the available swagger ui versions.

Directories

Path Synopsis
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.
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