echogger

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

README

echogger Build Status Go Report Card

Easy Swagger UI for your Echo API

Installation

If you want to install echogger.

go get -u github.com/KimMachineGun/echogger

Example

package main

import (
	"net/http"

	"github.com/KimMachineGun/echogger"

	"github.com/labstack/echo"
)

const PORT = "8080"

func main() {
	e := echo.New()

	config := echogger.Config{
		Flavor:   "swagger",
		BasePath: "v1",
		SubPath:  "document",
		DocPath:  "./swagger.yaml",
		JSONName: "spec.json",
	}

	e.Use(echogger.MiddlewareWithConfig(config))

	e.GET("/", func(c echo.Context) error {
		return c.String(http.StatusOK, "Hello world")
	})

	e.Start(":" + PORT)
}

If you use echogger.Middleware(), config is default value.

Default Value
Flavor:   "swagger"
BasePath: "/"
SubPath:  "docs"
DocPath:  "./swagger.yaml"
JSONName: "swagger.json"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware() echo.MiddlewareFunc

Middleware creates a middleware to serve a documentation site

func MiddlewareWithConfig

func MiddlewareWithConfig(config Config) echo.MiddlewareFunc

MiddlewareWithConfig creates a middleware with options to serve a documentation site

Types

type Config

type Config struct {
	DocPath  string
	BasePath string
	Flavor   string
	SubPath  string
	JSONName string
	NoUI     bool
}

Config configures the echogger middlewares

func (*Config) EnsureDefaults

func (c *Config) EnsureDefaults()

EnsureDefaults in case some options are missing

Jump to

Keyboard shortcuts

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