Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How would a forwardf work? #25

Closed
TWith2Sugars opened this issue Feb 6, 2018 · 11 comments
Closed

How would a forwardf work? #25

TWith2Sugars opened this issue Feb 6, 2018 · 11 comments

Comments

@TWith2Sugars
Copy link
Contributor

TWith2Sugars commented Feb 6, 2018

I'm attempting to create a forwardf extension to scope so that I can pass along an id to a sub resource.

let subResource projectId = scope {
  get "/" getAllItems projectId
  getf "/%i" getItem projectId
}

let project = scope {
  get "/" allProjects
  getf "/%i" getProject
  forwardf "%i/items" subResource 
}

that snippet probably explains it best on what I'm trying do.

I'm happy to create a pr and work on this but I'm not 100% sure how to go about this.

@Krzysztof-Cieslak
Copy link
Member

TBF, I'm not entirely sure why it's not implemented... Probably I've hit some problems with type system (scope implementation is bit hacky). But anyway, from top of my head, it should be fairly similar to other format function implementations in Router.fs - using addRouteF helper function.

@TWith2Sugars
Copy link
Contributor Author

I had an attempt before by following forward which I then found used subRoute and turns out subRouteF doesn't make sense.

I'll have another try and see if I can get around it.

@Krzysztof-Cieslak
Copy link
Member

I'm not sure if I 100% agree with @gerardtoconnor about this :D

@gerardtoconnor
Copy link

Im no phoenix / Saturn expert so dont mind me!

@Krzysztof-Cieslak
Copy link
Member

Krzysztof-Cieslak commented Feb 7, 2018

Oh, that has nothing really to do with Phoenix nor Saturn... I think

@gerardtoconnor
Copy link

My statement still stands, don't mind me ;)

@Krzysztof-Cieslak
Copy link
Member

Anyway, I believe that I've accidentally implemented fowardf adding some stuff to controller today - https://github.com/SaturnFramework/Saturn/blob/master/src/Saturn/Controller.fs#L68

@TWith2Sugars
Copy link
Contributor Author

well...., I think I'll still give it a shot at the scope level anyway :) .

@TWith2Sugars
Copy link
Contributor Author

Well looks like subroutef now exists, I'll wait until it's released and base my attempt around that.

@Krzysztof-Cieslak
Copy link
Member

Implemented in 756a3ab

@TWith2Sugars
Copy link
Contributor Author

Thanks for doing this, I was getting no where with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants