rest

package
v0.0.0-...-97d2db0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2017 License: MIT Imports: 10 Imported by: 2

Documentation

Overview

Package rest represent different types of rest types and its manipulations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	URL     string
	Method  string
	Handler http.Handler
}

Endpoint defines a single rest endpoint(route) in the server

type Endpoints

type Endpoints []*Endpoint

Endpoints represents an Endpoint slice.

func (Endpoints) Len

func (a Endpoints) Len() int

func (Endpoints) Less

func (a Endpoints) Less(i, j int) bool

func (Endpoints) Swap

func (a Endpoints) Swap(i, j int)

type JWTData

type JWTData struct {
	URL    string        `json:"url"`
	EXP    int           `json:"exp"`
	Secret string        `json:"secret"`
	Data   jwt.MapClaims `json:"data"`
}

JWTData represents jwt token details.

func (*JWTData) GetEndPoint

func (j *JWTData) GetEndPoint(rootPath string) (*Endpoint, error)

GetEndPoint send an endpoint for JWT token creation

type Resource

type Resource struct {
	Name    string            `json:"name"`
	Headers map[string]string `json:"headers,omitempty"`
}

Resource respresent a single resource in rest api.

func (*Resource) GetEndPoints

func (r *Resource) GetEndPoints(rootPath string) ([]*Endpoint, error)

GetEndPoints returns all the endpoints for this resource if the specified folder is not present it will send an error

type Static

type Static struct {
	URL  string `json:"url"`
	Path string `json:"path"`
}

func (*Static) GetEndPoint

func (s *Static) GetEndPoint(rootPath string) (*Endpoint, error)

type URL

type URL struct {
	URL         string            `json:"url"`
	Method      string            `json:"method,omitempty"`
	ContentType string            `json:"content_type,omitempty"`
	File        string            `json:"file,omitempty"`
	StatusCode  int               `json:"status,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
}

URL type represent a url resource in rest api Url is mandatory. ContentType defaults to application/json if not provided. Status code default to 200 Method defaults to GET if not provided.

func (*URL) GetEndPoint

func (u *URL) GetEndPoint(rootPath string) (*Endpoint, error)

GetEndPoint send an endpoint for the URL

Jump to

Keyboard shortcuts

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