Verified Commit 9eac5e1d authored by Camil Staps's avatar Camil Staps 🚀

Cleanup iTasks.Extensions.Web

parent 063c7a9f
Pipeline #29232 passed with stage
in 5 minutes and 12 seconds
definition module iTasks.Extensions.Web definition module iTasks.Extensions.Web
import iTasks import iTasks
from Internet.HTTP import :: HTTPMethod, :: HTTPRequest, :: HTTPResponse from Internet.HTTP import :: HTTPMethod, :: HTTPRequest, :: HTTPResponse
from Text.URI import :: URI from Text.URI import :: URI
from Text.HTML import class html from Text.HTML import class html
/** /**
* This module provides support for building web applications. * This module provides support for building web applications.
*/ */
//* Uniform resource locators //* Uniform resource locators
:: URL = URL !String :: URL = URL !String
...@@ -19,24 +21,38 @@ derive JSONDecode URL ...@@ -19,24 +21,38 @@ derive JSONDecode URL
derive gDefault URL derive gDefault URL
derive gEq URL derive gEq URL
//Simple web server task //* Simple web server task
serveWebService :: Int (HTTPRequest -> Task HTTPResponse) -> Task () serveWebService :: Int (HTTPRequest -> Task HTTPResponse) -> Task ()
//Task for serving a static file //* Task for serving a static file
serveFile :: [FilePath] HTTPRequest -> Task HTTPResponse serveFile :: [FilePath] HTTPRequest -> Task HTTPResponse
/** /**
* Calls an external HTTP webservice. * Calls an external HTTP webservice.
* *
* @param HTTP Method: the HTTP method (GET or POST) to use * @param HTTP Method: the HTTP method (GET or POST) to use
* @param URL: The URL of the webservice * @param URL: The URL of the webservice
* @param Parameters: A list of name/value pairs * @param Data: The body of the request
* @param Response handler: A parse function that parses the response * @param Response handler: A parse function that parses the response
* *
* @return The parsedd value * @return The parsed value
* *
* @gin-title Call web service * @gin-title Call web service
* @gin-icon webservice * @gin-icon webservice
*/ */
callHTTP :: !HTTPMethod !URI !String !(HTTPResponse -> (MaybeErrorString a)) -> Task a | iTask a callHTTP :: !HTTPMethod !URI !String !(HTTPResponse -> (MaybeErrorString a)) -> Task a | iTask a
/**
* Calls an external HTTP webservice.
*
* @param HTTP Method: the HTTP method (GET or POST) to use
* @param URL: The URL of the webservice
* @param Parameters: A list of name/value pairs
* @param Response handler: A parse function that parses the response
*
* @return The parsed value
*
* @gin-title Call web service
* @gin-icon webservice
*/
callRPCHTTP :: !HTTPMethod !URI ![(String,String)] !(HTTPResponse -> a) -> Task a | iTask a callRPCHTTP :: !HTTPMethod !URI ![(String,String)] !(HTTPResponse -> a) -> Task a | iTask a
implementation module iTasks.Extensions.Web implementation module iTasks.Extensions.Web
import iTasks import iTasks
import iTasks.UI.Editor.Controls, iTasks.UI.Editor.Modifiers import iTasks.UI.Editor.Controls, iTasks.UI.Editor.Modifiers
import Internet.HTTP, Text, Text.HTML, Text.URI, Text.Encodings.MIME, Text.Encodings.UrlEncoding, StdArray, Data.Either import Internet.HTTP, Text, Text.HTML, Text.URI, Text.Encodings.MIME, Text.Encodings.UrlEncoding, StdArray, Data.Either
...@@ -14,7 +15,6 @@ import qualified Data.Map as DM ...@@ -14,7 +15,6 @@ import qualified Data.Map as DM
import Data.Map.GenJSON import Data.Map.GenJSON
import qualified Data.List as DL import qualified Data.List as DL
//* URL
gText{|URL|} _ val = [maybe "" toString val] gText{|URL|} _ val = [maybe "" toString val]
gEditor{|URL|} = selectByMode gEditor{|URL|} = selectByMode
...@@ -215,5 +215,3 @@ callHTTP _ url _ _ ...@@ -215,5 +215,3 @@ callHTTP _ url _ _
callRPCHTTP :: !HTTPMethod !URI ![(String,String)] !(HTTPResponse -> a) -> Task a | iTask a callRPCHTTP :: !HTTPMethod !URI ![(String,String)] !(HTTPResponse -> a) -> Task a | iTask a
callRPCHTTP method url params transformResult callRPCHTTP method url params transformResult
= callHTTP method url (urlEncodePairs params) (Ok o transformResult) = callHTTP method url (urlEncodePairs params) (Ok o transformResult)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment