Skip to content

Commit

Permalink
Added support for 'geo' blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
atikhonov-avito authored and buglloc committed Apr 17, 2018
1 parent 5a6cb2c commit 6f0edbc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions gixy/directives/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,25 @@ def __init__(self, name, args):
def variables(self):
# TODO(buglloc): Finish him!
return [Variable(name=self.variable, value='', boundary=None, provider=self, have_script=False)]


class GeoBlock(Block):
nginx_name = 'geo'
self_context = False
provide_variables = True

def __init__(self, name, args):
super(GeoBlock, self).__init__(name, args)
if len(args) == 1: # geo uses $remote_addr as default source of the value
source = '$remote_addr'
variable = args[0].strip('$')
else:
source = args[0]
variable = args[1].strip('$')
self.source = source
self.variable = variable

@cached_property
def variables(self):
# TODO(buglloc): Finish him! -- same as in MapBlock
return [Variable(name=self.variable, value='', boundary=None, provider=self, have_script=False)]

0 comments on commit 6f0edbc

Please sign in to comment.