router

package
v6.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2017 License: MIT Imports: 3 Imported by: 0

README

Simplicity Equals Productivity

_future

This folder contains features that are marked as 'work-in-progress', they can take a long to be fully implemented and adopted to the Iris framework itself, even months.

Some people may find that bad idea, for many and different reasons, to upload them on that public repository so soon.

But I think that it is a good place for new developers to view and track how a feature is being implemented step-by-step. How I develop Iris step-by-step.

Inspiration for new Iris Developers.

I have collected some tips for you!

  • Do What They Think You Can't Do.
  • It's Not How Good You Are, It's How Good You Want To Be.
  • Genius is 1% Inspiration, 99% Perspiration.
  • You Are Your Only Limit.
  • Do Something Today That Your Future Self Will Thank You.
  • Don't Call It A Dream - Call It A Plan.

And never forget, If I can do it, so can you!

Any brilliant ideas of yours?

I'll be glad to talk with you about your awesome feature requests, open a new discussion there, you will be heard!

Documentation

Index

Constants

View Source
const (
	ParamNameSeperator = ':'
	FuncSeperator      = ' '
	FuncStart          = '('
	FuncEnd            = ')'
	FuncParamSeperator = ','
	FailSeparator      = '!'
)
View Source
const (
	PathSeparator = '/'
	// Out means that it doesn't being included in param.
	ParamStartOut = '{'
	ParamEndOut   = '}'
)
View Source
const DefaultFailStatusCode = 404

Variables

This section is empty.

Functions

This section is empty.

Types

type CursorState

type CursorState int
const (
	// no : is found yet
	CursorStateNone CursorState = iota
	// macro name and first expression guess parsed
	// and we' ready to walk forward
	CursorStateStarted
	// after space, waiting for a macro func begin or !+fail_status_code
	CursorStatePending
	// inside the macro func, after the opening parenthesis
	CursorStateRecording
)

we use that to set a value of each "state". because macro's function's arguments can accepts space and regex with any character

func (*CursorState) Is

func (cs *CursorState) Is(s CursorState) bool

type MacroFuncTmpl

type MacroFuncTmpl struct {
	// range
	Name string
	// 1,5
	Params []string
}

type MacroTmpl

type MacroTmpl struct {
	// int
	Name string
	// Macro will allow more than one funcs.
	// []*MacroFuncs{ {Name: range, Params: []string{1,5}}}
	Funcs []MacroFuncTmpl
}

type ParamTmpl

type ParamTmpl struct {
	// id
	Name string
	// int range(1,5)!fail # fail fails on int parse or on range, it will work reclusive
	Expression string
	// fail
	FailStatusCode int

	Macro MacroTmpl
}

func ParseParam

func ParseParam(source string) (*ParamTmpl, error)

Parse i.e: id:int range(1,5) otherFunc(3) !404

id = param name | can front-end end here but the parser should add :any int = marco | can end here

range = marco's funcs(range) 1,5 = range's func.params | can end here

+

otherFunc = marco's funcs(otherFunc) 3 = otherFunc's func.params | can end here

404 = fail http custom error status code -> handler , will fail rescuslive

type PathParamTmpl

type PathParamTmpl struct {
	SegmentIndex int
	Param        ParamTmpl
}

type PathTmpl

type PathTmpl struct {
	Params         []PathParamTmpl
	SegmentsLength int
}

func ParsePath

func ParsePath(source string) (*PathTmpl, error)

/users/{id:int range(1,5)}/profile parses only the contents inside {} but it gives back the position so it will be '1'

Directories

Path Synopsis
ast

Jump to

Keyboard shortcuts

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