Git Product home page Git Product logo

atc-router-cirun's Introduction

Name

ATC Router library for Kong.

Table of Contents

Semantics

At the core of the library, ATC Router is a DSL that supports simple predicate and logical combinations between the predicates.

Each data referred in the DSL has a type, the type can be one of the following:

  • "String" - a UTF-8 string value
  • IpCidr - an IP address range in CIDR format
  • IpAddr - a single IP address that can be checked against an IpCidr
  • Int - an 64-bit signed integer

APIs

resty.router.schema

new

syntax: s = schema.new()

context: any

Create a new schema instance that can later be used by router and context.

Back to TOC

add_field

syntax: res, err = s:add_field(field, field_type)

context: any

Adds the field named field into the schema. Type can be one of the ones mentioned in the Semantics section above.

If an error occurred, nil and a string describing the error will be returned.

Back to TOC

get_field_type

syntax: typ, err = s:get_field_type(field)

context: any

Gets the field type from the schema.

If an error occurred, nil and a string describing the error will be returned.

Back to TOC

resty.router.router

new

syntax: r = router.new(schema)

context: any

Create a new router instance that can later be used for performing matches. schema must refer to an existing schema instance.

Back to TOC

add_matcher

syntax: res, err = r:add_matcher(priority, uuid, atc)

context: any

Add a matcher to the router. priority is a 64-bit unsigned integer that instructs the priority for which the matchers should be evaluated. uuid is the string representation of the UUID of the matcher which will be used later for match results. atc is the matcher written in ATC DSL syntax.

If an error occurred or the matcher has syntax/semantics errors, nil and a string describing the error will be returned.

Back to TOC

remove_matcher

syntax: res, err = r:remove_matcher(uuid)

context: any

Remove matcher with uuid from the router.

Returns true if the matcher has successfully been removed. false if the matcher does not exist.

Back to TOC

execute

syntax: res, err = r:execute(context)

context: any

Executes the router against value provided inside the context instance.

context must use the same schema as the router, otherwise Lua error will be thrown.

Returns true if at least one matcher produced a valid match. false if the none of the matcher matched.

Back to TOC

get_fields

syntax: res, err = r:get_fields()

context: any

Returns the currently used field names by all matchers inside the router as an Lua array. It can help reduce unnecessarily producing values that are not actually used by the user supplied matchers.

Back to TOC

resty.router.context

new

syntax: c = context.new(schema)

context: any

Create a new context instance that can later be used for storing contextual information. for router matches. schema must refer to an existing schema instance.

Back to TOC

add_value

syntax: res, err = c:add_value(field, value)

context: any

Provides value for field inside the context.

Returns true if field exists and value has successfully been provided.

If an error occurred, nil and a string describing the error will be returned.

Back to TOC

get_result

syntax: uuid, matched_value, captures = c:get_result(matched_field)

context: any

After a successful router match, gets the match result from the context.

If matched_field is provided, then matched_value will be returned with the value matched by the specified field. If matched_field is nil or field did not match, then nil is returned for matched_value.

If the context did not contain a valid match result, nil is returned.

Otherwise, the string UUID, value matching field matched_field and regex captures from the matched route are returned.

Back to TOC

Copyright and license

Copyright (c) 2022 Kong, Inc.

Licensed under the Apache License, Version 2.0 <LICENSE or https://www.apache.org/licenses/LICENSE-2.0>. Files in the project may not be copied, modified, or distributed except according to those terms.

Back to TOC

atc-router-cirun's People

Contributors

aboudreault avatar bungle avatar dndx avatar hanshuebner avatar hutchic avatar javierguerragiraldez avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.