Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

function u_doc_wsRestfulStart()

  local nResult   	:= 0
  local jo        	:= Nil
  local cEnv      	:= getenvserver()
  local _Port_     	:= 40011
  local _Charset_       := "UTF8UTF-8"
  local _Server_        := "HTTP_SRV"
  local _Location_      := "HTTP_APP"
  local _ContentTypes_  := "APP_CONTENTTYPES"
  local _ThreadPool_    := "TP_APP"

  // HTTP Config
  // -----------
    jo := JsonObject():new()
    jo['HTTPSERVER'] := JsonObject():new()
    jo['HTTPSERVER']['Log']                 := .F.
    jo['HTTPSERVER']['Charset']             := _Charset_
    jo['HTTPSERVER']['Servers']             := {_Server_}
    jo['HTTPSERVER']['LoadJSON']            := .F.
    jo['HTTPSERVER']['OldUrns']             := .F.

  // Server Config
  // -------------
    jo[_Server_] := JsonObject():new()
    jo[_Server_]['HostName']                := "TOTVS_HTTP_SERVER"
    jo[_Server_]['Port']                    := _Port_
    jo[_Server_]['ContentTypes']            := _ContentTypes_
    jo[_Server_]['Locations']               := { _Location_ }

  // Aplicativo
  // ----------
    jo[_Location_] := JsonObject():new()
    jo[_Location_]['Path']                  := '/'
    jo[_Location_]['RootPath']              := "root/web"
    jo[_Location_]['DefaultPage']           := {"index.html"}
    jo[_Location_]['ThreadPool']            := _ThreadPool_

    // Configuração básica de Thread Pool
    jo[_ThreadPool_] := JsonObject():new()
    jo[_ThreadPool_]['Environment']         := cEnv
    jo[_ThreadPool_]['MinThreads']          := 1
    jo[_ThreadPool_]['MaxThreads']          := 4
    jo[_ThreadPool_]['MinFreeThreads']      := 1
    jo[_ThreadPool_]['GrowthFactor']        := 1
    jo[_ThreadPool_]['InactiveTimeout']     := 30000
    jo[_ThreadPool_]['AcceptTimeout']       := 10000

  // ContentTypes
  // ------------
    jo[_ContentTypes_] := JsonObject():new()
    jo[_ContentTypes_]['htm']               := "text/html"
    jo[_ContentTypes_]['html']              := "text/html"
    jo[_ContentTypes_]['js']                := "application/x-javascript"
    jo[_ContentTypes_]['css']               := "text/css"
    jo[_ContentTypes_]['txt']               := "text/plain"
    jo[_ContentTypes_]['json']              := "application/json"
    jo[_ContentTypes_]['stm']               := "text/html"
    jo[_ContentTypes_]['tsp']               := "text/html"

  // Inicializa serviço HTTP
  // -----------------------
    nResult := tlpp.rest.wsRestfulStart( jo, '/myrest' )

return nResult

...