Plack :: App :: Unpi

Servire tramite UNAPI
Scarica ora

Plack :: App :: Unpi Classifica e riepilogo

Annuncio pubblicitario

  • Rating:
  • Licenza:
  • Perl Artistic License
  • Prezzo:
  • FREE
  • Nome editore:
  • Jakob Voss
  • Sito web dell'editore:
  • http://search.cpan.org/~voj/

Plack :: App :: Unpi Tag


Plack :: App :: Unpi Descrizione

PLACK :: App :: UNAPI è un modulo perl che implementa un server UNAPI come applicazione PSGI. La richiesta HTTP viene indirizzata a diverse applicazioni PSGI in base al formato richiesto. L'applicazione PSGI è un riferimento del codice perl o un oggetto con un metodo di chiamata che ottiene una variabile di ambiente e restituisce un riferimento di array con la struttura definita come HTTP Response.Unapi è a Tiny HTTP API per interrogare risorse discretamente identificate in diversi formati. L'idea di base di UNAPI ha due parametri di query HTTP Get: ID come formato Identificatore di risorse Per selezionare un formato Formatif No (o NO supportato) viene specificato, un elenco di formati viene restituito come XML Document.synopsisCreate come questo : Usa PLACK :: App :: UNAPI; My $ app1 = sub {...}; # APP # PSGI che serve risorse in JSON MY $ APP2 = SUB {...}; # App PSGI che serve risorse in XML My $ App3 = sub {...}; # PSGI APP che serve risorse in testo normale UNAPI JSON => , xml => , txt => ; Esegui per esempio chiamando il Plackup YoutScript.PSGI e recupera: http: // localhost: 5000 /? id = abcformat = json # chiama $ app1-> ($ env); http: // localhost: 5000 /? ID = abcformat = xml # chiamate $ app2 -> ($ env); http: // localhost: 5000 /? ID = ABCFormat = TXT # chiamate $ app3 -> ($ env); http: // localhost: 5000 / # Elenco dei formati di formati http: // localhost: 5000 /? Formato = XML # Restituisce l'elenco dei formati http: // localhost: 5000 /? ID = ABC # Restituisce l'elenco delle applicazioni FormatSPSPSPI può essere Creato come sottoclasse di Plack :: Componente o come semplice Riferimento del codice: Usa Plack :: Richiesta; # Applicazione PSGI che serve risorse in JSON SUB GET_RESOURCE_AS_JSON {MY $ ID = Shift; ... restituire $ json; } My $ app1 = sub {My $ ID = Plack :: Richiesta-> Nuovo (Shift) -> Param ('ID') // ''; My $ JSON = Get_RESOURCE_AS_JSON ($ ID); restituire definito $ json? , ]: , ]; }; Per facilitare le applicazioni come sopra, Plack :: App :: Unpi esporta la funzione Wrapli che può essere utilizzata come questa: Usa Plack :: App :: Unpi; UNAPI JSON => wrapi (\ get_resource_as_json => 'application / json'), xml => wrapi (\ get_resource_as_xml => 'application / xml'), txt => wrapli (\ get_resource_as_plain => 'testo / plain'); Prodotto homepage


Plack :: App :: Unpi Software correlato