Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1037429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:51:04+00:00 2026-05-16T14:51:04+00:00

How is it possible to simply access to get and post attributes in lift

  • 0

How is it possible to simply access to get and post attributes in lift framework inside RestHelper?
There are no any explicit examples about it in documentation 🙁

package my.domain

import net.liftweb.http._
import net.liftweb.http.rest._
import net.liftweb.json.JsonAST._
import net.liftweb.json._
import net.liftweb.common.{Box,Full,Empty,Failure,ParamFailure}
import net.liftweb.mapper._


import ru.dmteam.model.{RssItem}

object ContentRest extends RestHelper {


    def getq: String = {
        val q = S.param("q")
        q.toString
    }

    serve {
        case "api" :: "static" :: _ XmlGet _=> <b>{getq}</b>

    }
}

I want to understand how to make lift show value of q when I am requesting http://localhost:8080/api/static.xml?q=test

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:51:04+00:00Added an answer on May 16, 2026 at 2:51 pm

    Lift uses Box rather than null to indicate if a parameter was passed. This allows the nice use of Scala’s for comprehension to chain together a nice request handler. I’ll let the code speak for itself:

    object MyRest extends RestHelper {
      // serve the q parameter if it exists, otherwise
      // a 404
      serve {
        case "api" :: "x1" :: _ Get _ =>
          for {
            q <- S.param("q")
          } yield <x>{q}</x>
      }
    
      // serve the q parameter if it exists, otherwise
      // a 404 with an error string
      serve {
        case "api" :: "x2" :: _ Get _ =>
          for {
            q <- S.param("q") ?~ "Param 'q' missing"
          } yield <x>{q}</x>
      }
    
      // serve the q parameter if it exists, otherwise
      // a 401 with an error string
      serve {
        case "api" :: "x2" :: _ Get _ =>
          for {
            q <- S.param("q") ?~ "Param 'q' missing" ~> 401
          } yield <x>{q}</x>
      }
    
      // serve the q, r, s parameters if this exists, otherwise
      // different errors
      serve {
        case "api" :: "x3" :: _ Get _ =>
          for {
            q <- S.param("q") ?~ "Param 'q' missing" ~> 401
            r <- S.param("r") ?~ "No 'r'" ~> 502
            s <- S.param("s") ?~ "You're s-less" ~> 404
          } yield <x><q>{q}</q><r>{r}</r><s>{s}</s></x>
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To phrase my question as simply as possible, is there a way to create
Is it possible to get multiple inputs of the same name to post and
I have read through about every possible solution online, and I get a different
Is there any nice way to use an unordered_map so that you can access
Is there any way to access a dynamically accessing member of a User- defined
Is it possible to simply auto-height a child div to the remaining height not
I would simply like to know if it is possible to load tumblr posts
I heard its hard but - possible. I simply want to do it cauz
In InterfaceBuilder, I'm creating the simplest possible UIButton, by simply dragging from the Library
Trying to get access to a page's DOM after rendering. I do not need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.