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

  • Home
  • SEARCH
  • 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 9005777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:14:07+00:00 2026-06-16T01:14:07+00:00

I have usual happstack case in which we have ServerPart Response MonadPlus in list

  • 0

I have usual happstack case in which we have ServerPart Response MonadPlus in list and. Then msum Chooses the one that does not fail and response generated and returned.

I have opinion that some actions – like cheking cookies – preparing connection context (authorising authenticated user, implementing counts, etc…) should be done in any incoming request – without any path info even defined yet.

Maybe there’s some buzzy word I still not knowing yet, specially for such kinds of staff. Could someone advice please?

  • 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-06-16T01:14:08+00:00Added an answer on June 16, 2026 at 1:14 am

    If you want to take certain actions for every request, you can add them in the do statement before your routing code. For example:

    module Main where
    
    import Happstack.Server
    
    main = simpleHTTP nullConf $ do incCounter
                                    mUser <- checkUserAuth
                                    resp <- msum [ part1
                                                 , part2
                                                 , part3 mUser
                                                 ]
                                    logResponse resp
                                    return resp
    

    That will always run incCounter and checkUserAuth. Then it will try the various routes.

    If one of the routes matches, it will then call logResponse, and then finally return the resp which will be sent to the user.

    Note that while incCounter and checkUserAuth will always be run, logResponse will only be run if one of the parts matches. If none do, then I am pretty sure the code will escape and return a 404. If you wanted logResponse to always run, then you could add a handler to the msum that always matches. For example:

                     resp <- msum [ part1
                                  , part2
                                  , part3 mUser
                                  , notFound $ toResponse "Sorry, page not found."
                                  ]
    

    That will almost always run. If one of the parts matches, but explicitly calls ‘escape’, then I am pretty sure logResponse still won’t be run. There are ways of dealing with that as well.

    But, the short answer is, if you want something to happen even time, just put it before your msum code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the usual type or namespace name does not exist error, except that
I have a usual iOS Cocos2d game. I start with a MainMenuViewController, which then
I have a usual login form consisting of two input fields, one for login,
I have my index page which posts a single entry instead of the usual
I have a web application that uses TONS of javascript, and as usual, there
I have the usual unordered list for a navigation menu with submenus... html: <ul>
I have a UITableViewController subclass that renders a list of pre-set categories and fetches
Please note that the following is an IE only issue (as usual...) I have
I've noticed an increasing number of Windows applications that do not have the usual
As it's usual when working with Happstack, I have been making my own server

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.