Giter VIP home page Giter VIP logo

gonginx's Introduction

Report Card Actions Status

Gonginx

Gonginx is an Nginx configuration parser helps you to parse, edit, regenerate your nginx config files in your go applications. It makes managing your balancer configurations easier.

Basic grammar of an nginx config file

%token Keyword Variable BlockStart BlockEnd Semicolon Regex

%%

config      :  /* empty */ 
            | config directives
            ;
block       : BlockStart directives BlockEnd
            ;
directives  : directives directive
            ;
directive   : Keyword [parameters] (semicolon|block)
            ;
parameters  : parameters keyword
            ;
keyword     : Keyword 
            | Variable 
            | Regex
            ;

API

Core Components

  • Parser is the main package that analyzes and turns nginx structred files into objects. It basically has 3 libraries, lexer explodes it into tokens and parser turns tokens into config objects which are in their own package,
  • Config package is representation of any context, directive or their parameters in golang. So basically they are models and also AST
  • Dumper is the package that holds styling configuration only.

Examples

TODO

  • associate comments with config objects to print them on config generation and make it configurable with dumper.Style
  • move any context wrapper into their own file (remove from parser)
  • Parse included files recusively, keep relative path on load, save all in a related structure and make that optional in dumper.Style
  • Implement specific searches, like finding servers by server_name (domain) or any upstream by target etc.
  • add more examples
  • link the parent directive to any directive for easier manipulation

Limitations

There is no known limitations yet. PRs are more than welcome if you want to implement a specific directive / block, please read Contributing before your first PR.

License

MIT License

gonginx's People

Contributors

0xjacky avatar cr4zyvv avatar gotosre avatar qba73 avatar riadafridishibly avatar tufanbarisyildirim avatar virusdefender 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.