resource

package
v0.0.0-...-4799e85 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2021 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// go-raml extension to express Catch-All URL params
	// for example /path/{path:*} is going to match:
	//  - /path/a    -> path = a
	//  - /path/a/b  -> path = a/b
	//  - /path/a/b/c -> path = a/b/c
	CatchAllRoute = "{path:*}"
)

Variables

This section is empty.

Functions

func GetResourceParams

func GetResourceParams(r *raml.Resource) []string

GetResourceParams get all params of a resource examples: /users : no params /users/{userId} : params 1 = userId /users/{userId}/address/{addressId : params 1= userId, param 2= addressId

func HasCatchAllInRootRoute

func HasCatchAllInRootRoute(apiDef *raml.APIDefinition) bool

HasCatchAllInRootRoute returns true if the given raml api definition has catch all route as root endpoint

Types

type ClientService

type ClientService struct {
	Name          string
	EndpointName  string
	FilenameNoExt string
}

ClientService defines a client service. client service is a module that handle a single root endpoint

func NewClientService

func NewClientService(rootEndpoint, displayName string) ClientService

type Method

type Method struct {
	*raml.Method
	MethodName string
	Endpoint   string

	Resource     *raml.Resource // resource object of this method
	Params       string         // methods params
	FuncComments []string
	// contains filtered or unexported fields
}

Method defines base Method struct

func (Method) IsCatchAllRoute

func (m Method) IsCatchAllRoute() bool

IsCatchAllRoute returns true if this method use go-raml Catch-All route

func (Method) Verb

func (m Method) Verb() string

Verb returns HTTP Verb of this method in all uppercase format

func (Method) VerbTitle

func (m Method) VerbTitle() string

VerbTitle returns HTTP Verb of this method in title format

type Resource

type Resource struct {
	APIDef   *raml.APIDefinition
	Name     string   // resource name
	Endpoint string   // root endpoint
	Methods  []Method // all methods of this resource
	*raml.Resource
}

Resource is Go code representation of a resource

func New

func New(apiDef *raml.APIDefinition, r *raml.Resource, endpoint string, sortMethod bool) Resource

New creates a resource definition

Jump to

Keyboard shortcuts

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