Questions tagged [nickel]

A web application framework for the Rust Programming Language.

21 questions
49
votes
1 answer

Cannot borrow captured outer variable in an `Fn` closure as mutable

This is my first day with Rust, but I'm trying to do something trivial, and I'm stuck. What I'm trying to do is to add an struct to a Vector, and return the result. What I'm trying is to create a very simple REST service which will store the data…
Erik Pragt
  • 13,513
  • 11
  • 58
  • 64
4
votes
2 answers

error: type parameter `D` must be used as the type parameter for some local type

I'm using Nickel.rs with MongoDB to build a RESTful api. I'd like to implement a generic Responder for the type mongodb::error::Result>. This is the implementation I wrote based on the examples I found for Responder: impl
menawi
  • 399
  • 3
  • 13
4
votes
1 answer

How to get the Authorization Bearer header?

I would like to get the Authorization Bearer header for OAuth purposes, but it looks a bit confusing reading the docs use nickel::{Nickel, JsonBody, HttpRouter, Request, Response, MiddlewareResult, MediaType}; // Get the full Authorization…
Marcos
  • 43
  • 3
3
votes
1 answer

Posting form data with nickel.rs works the first time, returns 404 subsequent times

I've created the following login form and accompanying template: main.rs #[macro_use] extern crate nickel; extern crate mustache; extern crate rustc_serialize; use std::collections::HashMap; use nickel::{Nickel, MediaType, HttpRouter}; use…
menawi
  • 399
  • 3
  • 13
3
votes
1 answer

How to select query's result to JSON in Rust and Nickel?

I use nickel.rs: router.get("/api/movies", middleware! { |request, response| let mut test_movies = r#"[ { "title": "Ironman"}, { "title": "The Walk"}, { "title": "Paddington"} ] "#; let json =…
shinriyo
  • 344
  • 3
  • 17
2
votes
1 answer

How to create a Nickel handler that uses a database connection?

I'm trying to do a simple extension to the comments example by creating a REST API and committing the post to the database. I'm creating the connection outside the scope of the handler itself which I'm assuming is where my problem lies. I'm just…
Mike Nishizawa
  • 1,410
  • 1
  • 14
  • 14
2
votes
2 answers

How do I parse parameters submitted by a form in Nickel.rs?

I'm building a web application with Rust and Nickel.rs. I have a route which submits a form with a POST request. I would like to be able to use the request data (the data returned from the form), but I'm not sure how to go about it. // This works…
user2840647
  • 1,236
  • 1
  • 13
  • 32
2
votes
1 answer

How to use multiple variables in routes with Nickel?

Nickel states that you can use variables in the URLs, which sounds very useful, but is it possible to use multiple variables? Something like: www.example.com/login/:userid?:apikey?:etc server.get("/start/:userid?:passwd", middleware! { |request| …
user3816764
  • 489
  • 5
  • 22
1
vote
1 answer

How to implement application state with Rust?

I'm exploring using nickel-rs for a web app, and as such I'm currently writing some basic programs that replicate behaviour that I've been able to implement with python and flask. For this specific case I wanted to track the number of requests that…
Dragury
  • 21
  • 4
1
vote
1 answer

How to render a webpage using the Nickel framework?

I'm trying to make a webpage that interacts with JavaScript and sends JSON data to Rust functions, then renders the www files. The structure of my project is: /.. /src /www |___index.html |___/css | |__style.css | …
Daedalus
  • 295
  • 2
  • 17
1
vote
1 answer

How to use 'on_send' method of Nickel response?

On a nickel web service I would like to execute a function when a response send finishes. I've found the 'on_send' method on this doc, but I can't get it to build. I get this error: type mismatch: the type…
plailopo
  • 683
  • 1
  • 7
  • 12
1
vote
1 answer

cannot borrow `*request` as mutable because it is also borrowed as immutable

I've written an endpoint in Rust using nickel.rs: { let client = client.clone(); let mongodb = MongoRepository::new(client, "rust-users".into()); router.put("/users/:id",middleware!(|request, mut response| { let id =…
menawi
  • 399
  • 3
  • 13
1
vote
1 answer

Rust Nickel Hello World tutorial throwing dependency error when run

I am learning Rust, and saw a post on http://reddit.com/r/rust yesterday for Nickel. As a Node.js developer in my free time, I was interested in checking this out. I downloaded the Rust 1.0.0-beta DMG from http://rust-lang.org. I followed the Hello…
robabby
  • 2,160
  • 6
  • 32
  • 47
0
votes
0 answers

How to set the Content-Length header in multiple routes using Nickel middleware?

As I understand it, middleware handlers are not suitable for this since they work before processing the request. My current solution is: router.get("/items/:id", middleware! { |request, mut response| // ... let data =…
Ilya
  • 51
  • 6
0
votes
1 answer

How to obtain documents which don't contain object with specific value inside an array

For example, I have two documents: { communication: "some data 1" users: [ { name: 'Peter', role: 'admin' gender: 'male' }, { name: 'John', role: 'guest' gender: 'male' } ] } { …
EA0906
  • 472
  • 6
  • 14
1
2