Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 29 2019 13:04
    madosuki starred SuaveIO/suave
  • Jan 28 2019 00:31
    delneg starred SuaveIO/suave
  • Jan 23 2019 02:35
    severmat52 starred SuaveIO/suave
  • Jan 18 2019 20:59
    ademar commented #723
  • Jan 18 2019 20:59

    ademar on master

    Corrected default port from 808… Merge pull request #723 from Wa… (compare)

  • Jan 18 2019 20:59
    ademar closed #723
  • Jan 18 2019 18:20
    WallaceKelly commented #723
  • Jan 17 2019 22:39
    WallaceKelly opened #723
  • Jan 17 2019 21:23
  • Jan 07 2019 03:51
    vijacques starred SuaveIO/suave
  • Jan 03 2019 22:49
    trbarrett closed #721
  • Jan 03 2019 22:49
    trbarrett commented #721
  • Jan 03 2019 16:28
    ademar commented #720
  • Jan 03 2019 16:14
    mamcx commented #720
  • Jan 03 2019 16:01
    ademar commented #720
  • Jan 03 2019 15:48
    mamcx commented #720
  • Jan 03 2019 15:28
    ademar commented #720
  • Jan 03 2019 14:34
    ademar commented #721
  • Jan 03 2019 13:02
    trbarrett opened #721
  • Jan 03 2019 01:54
    Nexus6 starred SuaveIO/suave
Paul Agron
@nimzi
Hoping someone would point me to it
Harald Steinlechner
@haraldsteinlechner
how do you create your endpoint?
    let config =
        { defaultConfig with
            bindings = [ HttpBinding.create HTTP IPAddress.Any (uint16 port) ] 
        }
did you try using ipadress.any in the bindings?=
Rishav Sharan
@rishavs
Hi guys. are there any benchmarks for Suave? I want to understand how well it stacks aginst Giraffe for simple postgres based api servers
Rishav Sharan
@rishavs
Thanks!
Marwan Rabbâa
@waghanza
@rishavs if you want to contribute to the first , be my guest (I'm the main maintainer)
Van Olivares
@volivaresh_gitlab
Hi everyone
Davide Palmisano
@dpalmisano_twitter

Hi everyone! I'm a newbie of both f# and Suave and I'm loving them both so far!

I have a question tho, which I'm struggling to find an answer to.
Is there a way I can read the request as a stream?

Something that would allow me to do things like:

let stream = ctx.request.Stream ()

and then consuming it incrementally?

thanks a lot in advance!

Ademar Gonzalez
@ademar
Hi @dpalmisano_twitter Not at the moment, the http request would have been already parsed and the body will be handed to you as a byte array.
Davide Palmisano
@dpalmisano_twitter
thanks a lot @ademar
Thomas
@ThomasD3_gitlab
Hi,
I've found quite a serious issue: when you register with AWS' SNS system, they send a confirmation message. The Form field provided by Suave isn't built properly,, but the RawForm contains the correct data
or is the form field limited in size?
Thomas
@ThomasD3_gitlab
after experimenting, this string: { "SubscribeURL" : "abc=3" } in the form field will cause Suave to not decode it properly
Luke Albao
@lukealbao
:wave: Not sure if anyone's around, but I haven't seen it said anywhere else. The suave.io certs seem to have expired and we're unable to consult online docs.
Ademar Gonzalez
@ademar
@lukealbao sorry about that. The certificate has been renewed now.
Florian Verdonck
@nojaf
Hi, is there any reason this request never ends?
        startWebServer
            defaultConfig
            (fun ctx ->
                async {
                    let path = ctx.request.path
                    printfn "path: %s" path

                    let body =
                        ctx.request.rawForm
                        |> System.Text.Encoding.UTF8.GetString

                    let responseBody =
                        sprintf "my response to: %s" body
                        |> System.Text.Encoding.UTF8.GetBytes

                    let response =
                        { status =
                              { code = int HttpStatusCode.OK
                                reason = "resource found" }
                          headers = []
                          content = HttpContent.Bytes responseBody
                          writePreamble = false }

                    return Some { ctx with response = response }
                })
Also, what does writePreamble do?
Ademar Gonzalez
@ademar
@nojaf The preamble is the first line of the http response, i.e HTTP/1.1 200 OK along with some headers. In your examplewritePreamble should be true otherwise it wont output a valid http response.
Florian Verdonck
@nojaf
Thanks Ademar! Works like a charm.
Florian Verdonck
@nojaf
Hi again @ademar , is there a better way to do:
POST
              >=> path "/ast-viewer/untyped-ast"
              >=> request (fun req ctx ->
                  async {
                      let json = req.BodyText

                      match! getUntypedAST json with
                      | GetUntypedASTResponse.Ok body -> return! (applicationJson >=> OK body) ctx
                      | GetUntypedASTResponse.InvalidAST errors -> return! (applicationText >=> BAD_REQUEST errors) ctx
                      | _ -> return failwith "meh"

                  })
let applicationJson = setMimeType "application/json"
let applicationText = setMimeType "application/text"
Ademar Gonzalez
@ademar
@nojaf yeah .. i think you do not need the async block nor the ctx param
I think this would work ..
    >=> path "/ast-viewer/untyped-ast"
    >=> request (fun req ->
          let json = req.BodyText
          match! getUntypedAST json with
          | GetUntypedASTResponse.Ok body -> (applicationJson >=> OK body)
          | GetUntypedASTResponse.InvalidAST errors -> (applicationText >=> BAD_REQUEST errors)
          | _ -> return failwith "meh")
Ademar Gonzalez
@ademar
hum .. i missed that getUntypedAST is async
Florian Verdonck
@nojaf
Yeah, I'm indeed struggling with the async nature of getUntypedAST
Florian Verdonck
@nojaf
Hi again, is this still accurate https://github.com/SuaveIO/suave/blob/master/examples/CORS/Program.fs
Still a lick confused when it comes to CORS.
I'm in a localhost scenario and I basically want to say: all good cors wise.
let corsConfig =
    { defaultCORSConfig with allowedUris = InclusiveOption.All
    // InclusiveOption.Some [ "http://localhost:8080" ]
     }
    let webPart =
        cors corsConfig
        >=> choose
                [ OPTIONS >=> OK "CORS accepted"
                  GET
                  >=> path "/ast-viewer/version"
                  >=> cors corsConfig
                  >=> setMimeType "text/plain"
                  >=> OK(getVersion ())
                  POST >=> path "/ast-viewer/untyped-ast" >=> untypedAst
                  POST >=> path "/ast-viewer/typed-ast" >=> typedAst
                  NOT_FOUND "Not found" ]
This works but I'm not sure it is the way to go.
Ademar Gonzalez
@ademar
@nojaf yeah I think that is OK
Ademar Gonzalez
@ademar
you could also do something more straightforward like
let setCORSHeaders hostname =
       Writers.addHeader "Access-Control-Allow-Origin" hostname
       >=> Writers.addHeader "Access-Control-Allow-Headers" "*"
       >=> Writers.addHeader "Access-Control-Allow-Methods" "*"
Florian Verdonck
@nojaf
Thanks @ademar