Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Using with PostgREST

Peter edited this page Feb 21, 2017 · 2 revisions

NGINX prepare


server {

       server_name pg.jats.science;

       root /var/www/pg/html;

       index index.html index.htm;

location / {
    try_files $uri $uri/ @proxy;
}

location @proxy {

          rewrite ^/urn:lex-do:br\;(?:rj|rio.janeiro)\;rio\.janeiro:(?:executivo|exe|legislativo|leg|judiciario|jud):materia:([0-9]+)$ /vw_con$

          rewrite ^/urn:issn:(\d\d\d\d)\-?(\d\d\d)/is[cC]$  /vwint_issn_isc?select=isc&issn=eq.$1$2   break;
          rewrite ^/urn:issn:(\d\d\d\d)\-?(\d\d\d)([0-9xX])/is[cC]$  /vwint_issn_isc?select=isc&issn=eq.$1$2&dig8=eq.$3   break;

          rewrite ^/urn:issn:(\d\d\d\d)\-?(\d\d\d)/is[nN]$  /vwint_issn_isn?select=isn&issn=eq.$1$2   break;
          rewrite ^/urn:issn:(\d\d\d\d)\-?(\d\d\d)([0-9xX])/is[nN]$  /vwint_issn_isn?select=isn&issn=eq.$1$2&dig8=eq.$3   break;

          rewrite ^/urn:issn:(\d\d\d\d)\-?(\d\d\d)/[nN]2[cC]$  /vwint_issn_n2c?select=issn-l&issn=eq.$1$2   break;
          rewrite ^/urn:issn:(\d\d\d\d)\-?(\d\d\d)([0-9xX])/[nN]2[cC]$  /vwint_issn_n2c?select=issn-l&issn=eq.$1$2&dig8=eq.$3   break;

          rewrite ^/urn:issn:(\d\d\d\d)\-?(\d\d\d)/[nN]2[nN]s?$  /vwint_issn_n2ns?select=issns&issn=eq.$1$2   break;
          rewrite ^/urn:issn:(\d\d\d\d)\-?(\d\d\d)([0-9xX])/[nN]2[nN]s?$  /vwint_issn_n2ns?select=issns&issn=eq.$1$2&dig8=eq.$3   break;

          rewrite ^/(.*)$ /$1 break;

          proxy_pass  http://127.0.0.1:3000;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          default_type  application/json;
          proxy_hide_header Content-Location;
          proxy_set_header  Connection "";
          proxy_http_version 1.1;
       }

}

SQL adaptations

CREATE VIEW vwint_issn_isc AS 
  SELECT issn, lib.issn_digit8(issn) as dig8, 
         (issn=issn_l) as isc 
  FROM lib.issn_l
;

CREATE VIEW vwint_issn_isn AS 
  SELECT issn, lib.issn_digit8(issn) as dig8, 
         true as isn 
  FROM lib.issn_l
;

CREATE VIEW vwint_issn_n2c AS
  SELECT issn, 
         lib.issn_digit8(issn) as dig8,
         lib.issn_cast(lib.issn_n2c(issn)) AS "issn-l" 
  FROM lib.issn_l
;

CREATE VIEW vwint_issn_n2ns AS
  SELECT issn,
         lib.issn_digit8(issn) as dig8,
         lib.issn_N2Ns_formated( issn ) AS issns 
  FROM lib.issn_l
;
Clone this wiki locally