models

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Host string `yaml:"host"`
	Port int    `yaml:"port"`
}

func (Address) String

func (a Address) String() string

type Config

type Config struct {
	Server Address `yaml:"server"`
	Routes []Route `yaml:"routes"`
}

type ContentType

type ContentType string

func (ContentType) Test

func (c ContentType) Test(targetContentType string) bool

type Form

type Form []string

func (Form) Test

func (f Form) Test(values url.Values, log *logger.Logger) bool

type JsonBody

type JsonBody []string

func (JsonBody) Test

func (j JsonBody) Test(r *http.Request, log *logger.Logger) bool

type Method

type Method string

func (Method) Test

func (m Method) Test(targetMethod string) bool

type Param

type Param []string

func (Param) Test

func (p Param) Test(path map[string]string, log *logger.Logger) bool

type Path

type Path string

func (Path) ExtractParameters

func (p Path) ExtractParameters(targetPath string) (map[string]string, error)

func (Path) Test

func (p Path) Test(targetPath string) bool

type Query

type Query []string

func (Query) Test

func (q Query) Test(values url.Values, log *logger.Logger) bool

type Route

type Route struct {
	Name   string `yml:"name,omitempty"`
	Method Method `yml:"method"`
	Path   Path   `yml:"path"`
	When   *When  `yml:"when,omitempty"`
	Then   *Then  `yml:"then,omitempty"`
}

func (Route) Match

func (o Route) Match(r *http.Request, log *logger.Logger) bool

type Then

type Then struct {
	Status  int      `yml:"status,omitempty"`
	Headers []string `yml:"headers,omitempty"`
	Body    string   `yml:"body,omitempty"`
}

func (Then) Respond

func (t Then) Respond(w http.ResponseWriter)

type When

type When struct {
	ContentType ContentType `yaml:"content_type"`
	Param       Param       `yaml:"param"`
	Query       Query       `yaml:"query"`
	Form        Form        `yaml:"form"`
	JsonBody    JsonBody    `yaml:"json_body"`
}

func (When) Test

func (w When) Test(r *http.Request, params map[string]string, log *logger.Logger) bool

Jump to

Keyboard shortcuts

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